Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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 ( [id://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.

Replies are listed 'Best First'.
Re^6: If you believe in Lists in Scalar Context, Clap your Hands
by ikegami (Patriarch) 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://719906]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-25 18:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found