in reply to I don't get map. How would I use map here?
First I'd reduce your two loops to one:
Then I'd substitute the map for the for:while (<DATA>) { print "$2\t=>$1\n" if /^(.*?)\s+(.*?)$/; } __DATA__ 0 5713813 276k CVS_RES 264k Desktop 17k Documes 33k SEARCH
As long as you are okay with there being a serious loss in readability, and it smacks of golf.map {print "$2\t=>$1\n" if /^(.*?)\s+(.*?)$/} <DATA>; __DATA__ 0 5713813 276k CVS_RES 264k Desktop 17k Documes 33k SEARCH
|
|---|