in reply to Re^4: Creating Multidimensional Hashed Arrays?
in thread Creating Multidimensional Hashed Arrays?

to add a new vlan assuming vlan number is unique
unless (exists $vlan_nums{$new_num}){ $vlan_nums{$new_num}{name} = xyz; .... }
If update is needed for the existing number you can add an else loop

Replies are listed 'Best First'.
Re^6: Creating Multidimensional Hashed Arrays?
by spickles (Scribe) on Aug 28, 2009 at 19:41 UTC

    The following code, taken from here, worked for me!

    # Either build your data as a hashref my $hashref = { username => someusername, etc => ..., }; # or assign a reference to a hash my %data = (username => someusername, etc => ...); my $hashref = \%data; # Then pass it off my $valid = verify($hashref); # You can also pass like so my $valid = verify(\%data); # Then, in your verify sub: sub verify { my $ref = shift; # do something with your data $ref->{'username'} =~ /yourregex/; return $something; }