Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Re: Dynamic array names

by Masem (Monsignor)
on Feb 10, 2001 at 01:43 UTC ( #57489=note: print w/replies, xml ) Need Help??


in reply to Re: Dynamic array names
in thread Dynamic array names

OOTOMH:
my %serviceHash;
while (<INPUT>) {
    /^(\d*)\.(\d*)\:(\S*)$/;
    if ( !defined( $serviceHash{ $1 } ) ) {
        my @array = ();
        $serviceHash{ $1 } = \@array;
    }
    $($serviceHash{ $1 })[ $2 ] = $3;
}
You can then do a foreach over the keys of the hash, and do the necessary processing from there. (Update: damn those gt and lt's!)

Replies are listed 'Best First'.
Re (tilly) 3: Dynamic array names
by tilly (Archbishop) on Feb 10, 2001 at 07:55 UTC
    If you wish to paste in code, please use the <code>...</code></code> tags. That not only gives easy formatting, but it also makes your code available from clicking on "d/l code".

    UPDATE
    Since tye complained, here is an example of what the CODE tag looks like:

    foreach (split //, "Just another Perl hacker,\n") { print; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2021-09-27 14:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?