in reply to better way to convert a string into an array and an hash
I don't know if it's better, but you can do this:
my $string = "1:1,2:1,3:2,500:2,505:1"; my %hash = split /[:,]/, $string; my @array = keys %hash;
Whether it's better depends on how much you know and can guarantee about your data. :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: better way to convert a string into an array and an hash
by dragonchild (Archbishop) on Oct 05, 2004 at 15:08 UTC | |
by duff (Parson) on Oct 05, 2004 at 15:27 UTC |