Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Getting single element from an array

by gurpreetsingh13 (Scribe)
on Nov 01, 2012 at 09:05 UTC ( [id://1001781]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    print ("adf","ff","f"); # Gladly prints the list
    print ("adf","ff","f")[1]; #Gives a syntax error
    $val=("adf","ff","f")[1];print $val; #Works easily
    print join "",("adf","ff","f"); #Works
    print join "",("adf","ff","f")[1]; #Works since treated in list contex
    +t
    
  2. or download this
    (sort {$a<=>} @lst)[0] # an alternative way to get min value from some
    + numeric list.
    
  3. or download this
    obj.method()[2] #when we know that method returns an array
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1001781]
Approved by Ratazong
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-03-28 23:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found