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; }