__test-code__
use warnings;
use strict;
my $test_s = 'hi [how are you]';

my $data;
if ( $test_s =~ m/\[.+\]/ ) {
    $data = $1;
}
__END__

is there easier way to do this
I was hoping something like this would work

$data = ($test_s =~ m/\[.+\]/); but does not work.. I tried @data too but still don't work.. I want to assign what was matched directly into the variable without going through if statement.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to