D
Dave
I regularly use something along the lines of:
my $string = 'some string to match';
my @match = '';
if ( @match = $string =~ /(pattern)/ ) {
print "The match is\n@match\n";
}
else {
print "Sorry, Dave. No match.\n";
}
to test a regex by printing what matches. However, if the regex becomes
unwieldly and I assign it to a variable:
my $regex = qr{pattern};
my $string = 'some string';
my @match = '';
print "@match = $string =~ $regex\n"
I get a '1' returned instead of the matched bits.
If someone can let me know how to rewrite the above, I'd be grateful.
Thanks.
my $string = 'some string to match';
my @match = '';
if ( @match = $string =~ /(pattern)/ ) {
print "The match is\n@match\n";
}
else {
print "Sorry, Dave. No match.\n";
}
to test a regex by printing what matches. However, if the regex becomes
unwieldly and I assign it to a variable:
my $regex = qr{pattern};
my $string = 'some string';
my @match = '';
print "@match = $string =~ $regex\n"
I get a '1' returned instead of the matched bits.
If someone can let me know how to rewrite the above, I'd be grateful.
Thanks.