DoubleBond has asked for the wisdom of the Perl Monks concerning the following question:
I'd like to seek the advice of the forum on a simple question
e.g.
my $parse = ' '; my $test_line = 'Happy Birthday'; $test_line =~/(Happy).*/; $parse = $1; print "parse = $parse\n";
Result would be:
,but if I combine line 3 and 4 to:parse = Happy
$parse = $test_line =~/(Happy).*/;
The result would be:
parse = 1
I understand that '1' means 'true' in this case, but I don't understand why can't I get the text 'Happy'.
I see the following syntex all the time, but for some reasons it doesn't work for me.
$var = $line =~ /pattern/;
I tried looking for similar cases online, but couldn't find one.
Thank you so much,
DB
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex question
by Corion (Patriarch) on May 06, 2014 at 14:12 UTC | |
|
Re: Regex question
by mr_mischief (Monsignor) on May 06, 2014 at 14:23 UTC | |
by AnomalousMonk (Archbishop) on May 07, 2014 at 05:06 UTC | |
|
Re: Regex question
by Laurent_R (Canon) on May 06, 2014 at 17:36 UTC | |
|
Re: Regex question
by DoubleBond (Initiate) on May 10, 2014 at 02:38 UTC |