go ahead... be a heretic | |
PerlMonks |
Re: Regex questionby betterworld (Curate) |
on Oct 14, 2008 at 09:48 UTC ( [id://716930]=note: print w/replies, xml ) | Need Help?? |
This will work: my ($number) = $data =~ /\d+/g;The match operator returns the matched substrings only in list context, which is why your first code worked (assignment to an array). By using extra parentheses (like in my code above), you can turn a scalar assignment into a list assignment. Update: You won't need the /g flag if you use capturing parentheses:
In Section
Seekers of Perl Wisdom
|
|