Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: how to find the how many elements are present in an array

by dsheroh (Parson)
on Jan 19, 2014 at 10:03 UTC ( #1071174=note: print w/ replies, xml ) Need Help??


in reply to Re^2: how to find the how many elements are present in an array
in thread how to access each element in an array?

There is no '4' element in $array[0] for you to access. $array[0] is the string "4601". It is not an array (or an array reference), exactly like the error message you quoted says:

Can't use string ("4601") as an ARRAY ref
Because it is not an array, it has no elements for you to access.

Perhaps you're coming from C and assuming that strings are arrays of characters? If so, then you need to understand that they aren't. In Perl, a string is a basic data type. A single value. Not an array of characters.


Comment on Re^3: how to find the how many elements are present in an array
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2015-07-30 08:47 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 (270 votes), past polls