Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Re(2): What Is 'my' Interested In?

by theorbtwo (Prior)
on Jan 30, 2004 at 17:49 UTC ( [id://325321]=note: print w/replies, xml ) Need Help??


in reply to Re(2): What Is 'my' Interested In?
in thread What Are Your Live Journal Friends Interested In?

Actualy, the last trick has nothing to do with the return of the my function -- an empty () would work just as well, and not effect what goes in @a at all.


Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Replies are listed 'Best First'.
Re: Re: Re(2): What Is 'my' Interested In?
by ysth (Canon) on Jan 30, 2004 at 18:43 UTC
    Either you are mistaken or I misunderstand you.
    $perl -MData::Dumper -we 'my @a = my ($x,$y,$z) = localtime;print Dump +er \@a' $VAR1 = [ 38, 27, 10 ]; $perl -MData::Dumper -we 'my @a = () = localtime;print Dumper \@a' $VAR1 = [];
    In both cases @a is assigned the result of the ...=localtime list assignment. And as perlop says, "a list assignment in list context produces the list of lvalues assigned to". In the my() case, the lvalues are the ones returned by my(). Though there seems to be a bug here:
    $perl -MData::Dumper -we 'my @a = my (undef,$y,$z) = localtime ;print Dumper \@a' $VAR1 = [ 49, 32, 10 ];
    I would have expected [undef,32,10] there.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-03-29 13:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found