in reply to Re: Hash of Arrays and File Operations
in thread Hash of Arrays and File Operations
I am trying to use map but it doesn't seem to be working. I tried doing it as :
@cols[1 .. $#cols] = map(tr /[1,2]/[0,1]/, @cols)
Also, do u think doing (i)split and getting the values as $id and @cols; then doing (ii)join to get the cols as scalar values so that we can do translate and then do (iii) split again to get the array value so that I can store it in the hash of arrays a good idea ?? for eg:
my %data; while (<DATA>) { next if /^id/; my ($id, @cols) = split; ## first split my $cols = join('',@cols); ## Join @cols = split('',$cols); ## and then split push @{ $data{$id} }, \@cols; }
I am having second thoughts about this method as it may lead to slower process or it might not be a good programming practice. Please Advise.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Hash of Arrays and File Operations
by toolic (Bishop) on Jan 28, 2010 at 20:15 UTC | |
by Anonymous Monk on Jan 28, 2010 at 20:24 UTC | |
by snape (Pilgrim) on Jan 28, 2010 at 22:38 UTC | |
by Anonymous Monk on Jan 28, 2010 at 22:56 UTC | |
by snape (Pilgrim) on Jan 29, 2010 at 14:44 UTC |