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;
In reply to Re^3: Hash of Arrays and File Operations
by toolic
in thread Hash of Arrays and File Operations
by snape
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |