Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Referncing a local array outside

by edoc (Chaplain)
on Dec 16, 2003 at 13:49 UTC ( #315057=note: print w/replies, xml ) Need Help??


in reply to Referncing a local array outside

you could ditch the temporary variable altogether..

#!/usr/bin/perl use strict; my %alink; # Create some arrays of random numbers... foreach my $name ('Fred', 'Barney', 'Wilma', 'Peggy'){ for (my $i = 0; $i < 5; $i++){ push( @{$alink{$name}}, int(rand(30)) ); } } foreach my $key (keys %alink){ foreach my $element ( @{$alink{$key}} ){ print $key,' ',$element,"\n"; } }

(also added 'use strict;' and then 'my' declarations as required.)

cheers,

J

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (1)
As of 2022-01-26 06:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (69 votes). Check out past polls.

    Notices?