Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^5: If you believe in Lists in Scalar Context, Clap your Hands

by ysth (Canon)
on Oct 28, 2008 at 04:51 UTC ( #719906=note: print w/ replies, xml ) Need Help??


in reply to Re^4: If you believe in Lists in Scalar Context, Clap your Hands
in thread If you believe in Lists in Scalar Context, Clap your Hands

Wrong. Don't forget that plain = is the scalar assignment operator, unless there is a hash or array on the left. ()= is the list assignment operator:

$ perl use strict; use warnings; my ($i,$j); sub f :lvalue { ($i,$j) } (f()) = (4,5); print("$i,$j\n"); __END__ 4,5
However, I would be very leery of using a relatively new feature like that that has probably not been used much in that way.


Comment on Re^5: If you believe in Lists in Scalar Context, Clap your Hands
Download Code
Re^6: If you believe in Lists in Scalar Context, Clap your Hands
by ikegami (Pope) on Oct 28, 2008 at 10:21 UTC

    Ah thanks, (although, not just "()=" is the list assignment operator).

    I would be very leery of using lvalue subs *in any way*.

Re^6: If you believe in Lists in Scalar Context, Clap your Hands
by JavaFan (Canon) on Oct 28, 2008 at 11:05 UTC
    Which relative new feature are you refering to? lvalue subs have been around since at least 5.6.0, and maybe even before that.
      The "relatively" new feature I meant is lvalue subs, yes. I wasn't saying not to use them at all; the "like that" meant to avoid using them in uncommon ways. Or do thorough testing on all perl versions you expect to use. Since I don't know of a specific problem, this counts as FUD, but I am unrepentant.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2014-11-24 07:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (137 votes), past polls