Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^5: Not understanding 2 sentences in perldoc

by haukex (Bishop)
on Jul 29, 2020 at 20:40 UTC ( #11120014=note: print w/replies, xml ) Need Help??


in reply to Re^4: Not understanding 2 sentences in perldoc
in thread Not understanding 2 sentences in perldoc

The assignment my ($x, $y, $z) = qw( 1 2 3 ) happens first, i.e. those three variables are assigned the numbers 1 to 3, and this first assignment returns the lvalues, to which the values qw( a b c ) are immediately assigned. Update: In other words, the numbers are assigned to the variables, but then immediately overwritten. Since this is just some example code it doesn't make much sense here, but in theory, you could for example be assigning to tied variables where assigning to the variable has some side effect, then it would make a difference.

Replies are listed 'Best First'.
Re^6: Not understanding 2 sentences in perldoc
by LanX (Cardinal) on Jul 29, 2020 at 21:35 UTC
    > it doesn't make much sense here,

    I'm often using it for setting defaults before unpacking @_ which could have 0,1 or 2 arguments

     ( my ($x,$y) = (42,666) ) = @_;

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      I'm often using it for setting defaults before unpacking @_ which could have 0,1 or 2 arguments

      Sure, that makes sense ;-) With "it doesn't make much sense here" I meant the specific example with fixed values.

        I know you know, but I also know others don't know better.

        You know? ;)

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11120014]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2021-01-22 00:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?