in reply to Parsing bizarre non delimted data and hash slices
to@new_hashes = map{ my $x = $_; +{ map { $_=>$x->{$_} } @wanted_keys } +} @old_hashes;
Update: I see someone else already said that. To provide some new content, here's a different answer to the second question:@new_hashes = map { my %x; @x{@wanted_keys}=@$_{@wanted_keys}; \%x } @ +old_hashes; # untested
@cols = (split(' ', $data, 4), (map scalar reverse, reverse split(' ', reverse($data), 4))[1 +..3]);
or the all in one version:@cols = split(' ', $data, 4); @cols[7,6,5,4,3] = map scalar reverse, split ' ', reverse($cols[3]), 5 +;
Side note: ${\(expr)} does the same thing as (expr)[-1], and in fewer characters if you can omit the parentheses.@cols = ((split(' ', $data, 4))[0..2], reverse map scalar reverse, spl +it ' ', reverse((split ' ', $data, 4)[-1]), 5);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Parsing bizarre non delimted data and hash slices
by Not_a_Number (Prior) on Feb 01, 2004 at 15:39 UTC |