Reputation: 892
my $s = '>P1;MOREWORDS';
if ($s =~ m/^>.{2};.*/) {
print "jjjjj\n";
my $or = $s =~ /^>.{2};(.*)/;
}
When I try to print $or
, I get 1
, instead of of MOREWORDS
I am trying to capture using (.)
, but failing to do so.
It correctly prints jjjjjj
after the match
Upvotes: 1
Views: 93
Reputation: 242383
Match returns a boolean in scalar context. Force list context to make it return the captured strings:
my ($or) = $s =~ /^>.{2};(.*)/;
Upvotes: 4