in reply to Re: hash 2 array ?
in thread hash 2 array ?
I would do it like this:$hash{$_} = { content => $hash{$_}, position => $i++ } for sort keys % +hash;
in other words, prefix the ordinal number packed at the beginning of the string. Then, when you either need the linenumber and/or the original string, use unpack:$hash{$_} = pack( 'N',$i++).$hash{$_} for sort keys %hash;
Lizmy ($line,$string) = unpack( 'Na*',$hash{$key} );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: hash 2 array ?
by halley (Prior) on Sep 15, 2003 at 15:44 UTC | |
by liz (Monsignor) on Sep 15, 2003 at 17:47 UTC |