Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

@F[6] vs. $F[6] - The Wrong Answer

by Elgon (Curate)
on Feb 21, 2003 at 00:01 UTC ( #237277=note: print w/ replies, xml ) Need Help??


in reply to Autosplit-Mode and $F[6] vs @F[6]

Hi Strat,

What is happening here is related to the way that Perl looks at individual values (scalars) and lists of values (arrays.) When you are referring to the whole list, stored in @F, say in a foreach loop...

foreach $_(@F) # For each value in the list called @F { # Do stuff... }
...then you should use the @ prefix but when you want a single, discrete value within @F, such as $F[6], say in the following if clause...
if ($F[6]) # If the seventh individual value in @F is true { # Do stuff }

...then you should use $F[6]. Essentially, if you're trying to access a single value then you'll want $, a list of values @ and a hash of key/value pairs %. Type "perldata" into the search box at the top of any perlmonks page and hit the search button. This should explain all you wish to know.

Elgon

Update : Apologies to all concerned, I completely misread the question in my eagerness to provide an answer. Please ignore the above. *Goes very red*

"What this book tells me is that goose-stepping morons, such as yourself, should read books instead of burning them."
       - Dr. Jones Snr, Indiana Jones and the Last Crusade]


Comment on @F[6] vs. $F[6] - The Wrong Answer
Select or Download Code
Re^2: Autosplit-Mode and $F[6] vs @F[6]
by Aristotle (Chancellor) on Feb 21, 2003 at 00:07 UTC
    If you read his post carefully you'll find he actually does know this.

    Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (14)
As of 2014-08-27 14:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (238 votes), past polls