Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: check if an element exists in array

by jethro (Monsignor)
on Apr 19, 2008 at 11:06 UTC ( [id://681642]=note: print w/replies, xml ) Need Help??


in reply to check if an element exists in array

If the Hash of Arrays is too high tech for you, you could also simply concatenate the numbers in a comma seperated string, so that Jims entry would be "12,57".

The if statement in mscharrers code would then look like:

if (!exists $people{$name}) { $people{$name} = $value; # store array with one value } else { $people{$name} .= ",$value"; # push 2nd,3rd,.. value on array
You can just print the string stored in the hash or get at the numbers with my @numbers= split /,/,$value

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-26 00:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found