Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Perl Idioms Explained - @ary = $str =~ m/(stuff)/g

by CountZero (Bishop)
on Sep 15, 2003 at 13:43 UTC ( #291552=note: print w/replies, xml ) Need Help??


in reply to Perl Idioms Explained - @ary = $str =~ m/(stuff)/g

One should perhaps add, that the real reason why this magic works is because "=~" binds more thightly than "=", so the regex gets done first and then its results are evaluated in list-context (which is provided by using an array as an L-value).

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Replies are listed 'Best First'.
Re: Re: Perl Idioms Explained - @ary = $str =~ m/(stuff)/g
by tachyon (Chancellor) on Sep 15, 2003 at 14:02 UTC

    To be completely pedantic the reason it 'works' is that they coded it that way! The reason it works without needing parens is as you say.

    The precedence order is why you need to do stuff like this:

    (my $fix_up = $old_str ) =~ s/this/that/g;

    But that is another idiom I guess. This one lets you set declare $fix_up, set it to $old_str, and then modify $fix_up in one line, while leaving $old_str intact for future reference.....

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://291552]
help
Chatterbox?
[Discipulus]: choroba if let your company to hire Tanktalus and marioroy ... what a big fishing!
[Discipulus]: i choice prague!!
[choroba]: 1200 years is enough :-)
[marioroy]: Lady_Aleena my $ans = qx! find . -name "*.pl" -exec ls -l {} \\; !;
[Tanktalus]: My basic problem right now is that if I were willing to move, I could be back in Toronto with a pay raise. We have a number of reasons for not wanting to do that.
[marioroy]: I had to backslash the backslash inside qx.
[Tanktalus]: marioroy++ # nice catch
[Lady_Aleena]: marioroy, that makes kinda makes sense.
[Discipulus]: yes i can survive also in younger town.. but when i passed i saw many strange letters..
[Lady_Aleena]: marioroy, sorry, I am not making sense right now.

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2017-04-23 20:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (432 votes). Check out past polls.