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

Re: Strange construct

by halley (Prior)
on Sep 07, 2011 at 19:46 UTC ( #924650=note: print w/ replies, xml ) Need Help??


in reply to Strange construct

This method must return a list, and the fifth element was the only thing useful to the caller. Expanding it out, it may make more sense.

my $bg = ($c->itemconfigure(qw/current -background/))[4];
my @values = $c->itemconfigure(qw/current -background/); my $bg = $values[4];

You often see this for builtin functions like stat() or localtime(). They return lists of potentially useful stuff, but you may only need one thing. The documentation for each one clearly shows the meaning of each returned value in a list of returned values.

--
[ e d @ h a l l e y . c c ]


Comment on Re: Strange construct
Select or Download Code
Re^2: Strange construct
by AnomalousMonk (Monsignor) on Sep 07, 2011 at 20:05 UTC
    ... you may only need one thing.

    And if you need more than one thing, that can be handled, too:

    >perl -wMstrict -le "my @ra = (qw(start a b c e l p r y z end))[-1, 6, 4, 7, 5, 1..3, 0]; ;; printf qq{'$_' } for @ra; " 'end' 'p' 'e' 'r' 'l' 'a' 'b' 'c' 'start'

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2014-07-30 14:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (234 votes), past polls