Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
XP is just a number
 
PerlMonks  

Re: new to perl, syntax question

by ikegami (Pope)
on Feb 20, 2012 at 03:42 UTC ( #954972=note: print w/ replies, xml ) Need Help??


in reply to new to perl, syntax question

The index expression of $array[ EXPR ] is evaluated in scalar context, and the an array in scalar context evaluates to the number of elements in the array.

my @folder = qw( a b c d e f ); my @name = qw( x y z ); my $var = $folder[@name]; # $var = 'd', since @name == 3.


Comment on Re: new to perl, syntax question
Select or Download Code
Re^2: new to perl, syntax question
by tics (Initiate) on Feb 21, 2012 at 06:44 UTC

    Thanks ikegami, for the wonderful explanation ! And I really appreciate the example. It really helps a lot.

    And thanks for the other suggestions as well. I'm really glad I chanced upon this forum. I did thought of making use of print to try figuring out what the statements would do, but the Internet connection here is really awful. So I gave up downloading Strawberry Perl.

    Only could resort to trying to understand the code using Notepad++.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2014-04-20 09:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls