in reply to Re^2: Hash of Arrays and File Operations
in thread Hash of Arrays and File Operations
I'm no tr expert, but isn't tr /[1,2]/[0,1]/ more simply written as tr/12/01/?@cols[1 .. $#cols] = map(tr /[1,2]/[0,1]/, @cols)
The following will replace all 1's with 0's, and all 2's with 1's, in all elements of the @cols array. It modifies the array in-place.
map { tr/12/01/ } @cols;
Update: I concur with AnonyMonk's hint that it is better written as:
tr/12/01/ for @cols;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Hash of Arrays and File Operations
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 |