in reply to Re: How do i get string between
in thread How do i get string between

Better to test the match result. Consider:

#!/usr/bin/perl use strict; use warnings; for my $str ('Matched', 'No match') { $str =~ /(\w*ed)/; print "defined: Matched $1 for '$str'\n" if defined $1; } for my $str ('Matched', 'No match') { print "match: Matched $1 for '$str'\n" if $str =~ /(\w*ed)/; }

Prints:

defined: Matched Matched for 'Matched' defined: Matched Matched for 'No match' match: Matched Matched for 'Matched'
True laziness is hard work