Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Do values from string exist within array?

by talexb (Canon)
on Sep 30, 2013 at 16:37 UTC ( #1056386=note: print w/replies, xml ) Need Help??

in reply to Do values from string exist within array?

Do you actually have a structure that looks like this?

my %hash = ( 'GrpID' => [ 123, 456 ] );

That would be a hash with a single key, whose value is an arrayref. You could find out how many values were present by looking at the value of scalar @{$hash{'GrpID'}} -- in this example, the value should be 2, meaning there are multiple values.

And you'd put values into that hash entry with

push ( @{$hash{'GrpID'}}, 789 );
I'd recommend you pop into the Perl debugger and try this stuff out. The debugger's a great place to try out Perl constructs.

Alex / talexb / Toronto

Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1056386]
NodeReaper lights some incense and reads Tool and Die

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2018-01-22 05:33 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (231 votes). Check out past polls.