Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Initializing a hash using a foreach loop

by Roy Johnson (Monsignor)
on Nov 29, 2004 at 19:37 UTC ( [id://411023]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    %ServerStatus = ();
    foreach my $i (0..$num) {
      $ServerStatus{$Ip[$i]} = [$Names[$i], 'unknown'];
    }
    
  2. or download this
    %ServerStatus = map {($Ip[$_], [$Names[$_], 'unknown'])} 0..$num;
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-18 06:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found