Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Print element using array reference

by arc_of_descent (Hermit)
on Apr 21, 2010 at 12:45 UTC ( #836046=note: print w/ replies, xml ) Need Help??


in reply to Print element using array reference

In the first expression, what you're doing is actually accessing an array slice.

@friends = qw(gobi guru muthu kumar sabari naga bal); print @friends[ 2, 4 ]; # prints muthu and sabari

If a list is accessed in scalar context, Perl will return the last element.


Comment on Re: Print element using array reference
Download Code
Replies are listed 'Best First'.
Re^2: Print element using array reference
by gobisankar (Acolyte) on Apr 21, 2010 at 16:44 UTC
    Thanks friends

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (10)
As of 2015-07-28 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (254 votes), past polls