Dear Monks,
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:
parse = Happy
,but if I combine line 3 and 4 to:
$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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.