Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: The mystery of $->[1]

by kcott (Bishop)
on Jul 11, 2015 at 20:59 UTC ( #1134317=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $ perl -MO=Deparse,-p -e 'my $l = ref $a eq "ARRAY" ? ($a->[0] || $->[
    +1]) : $a;'
    (my $l = ((ref($a) eq 'ARRAY') ? ($a->[0] || ($- > [1])) : $a));
    -e syntax OK
    
  2. or download this
        # Deal with the case of an item actually being an array ref to 1 o
    +r 2
        # hashrefs. Don't assign to $a or $b, as they're aliases to the or
    +ignal
        my $l = ref $a eq 'ARRAY' ? ($a->[0] || $->[1]) : $a;
        my $r = ref $b eq 'ARRAY' ? ($b->[0] || $->[1]) : $b;
    
  3. or download this
        my $l = ref $a eq 'ARRAY' ? ($a->[0] || $a->[1]) : $a;
        my $r = ref $b eq 'ARRAY' ? ($b->[0] || $b->[1]) : $b;
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2022-05-23 19:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (82 votes). Check out past polls.

    Notices?