oldtobor
- 132
- 0
OK, I may not know a lot of things and may have a lot of things wrong. But I am sure that PERL at least was definitely the route that languages should have taken.
For example to extract the next to the last field of an ascii file separated by "|" and sort them, it can be done with one line: C:\> perl -ane"split/\|/; $l=@_[@_-2];push@r,$l.\"\n\"if$l;END{print sort@r}" bands.txt
works on any unix too.
I find it amazing that back in the mid 1990s, just when Java started to become popular this direction of language design, and maybe greatly improving the concepts, compilers etc. did not take off. The syntax could be cleaner very BASIC like at least, there are so many improvements conceivable but the ideas are great:
split - it is implied that the line is split and the result is in an array called @_.
@_[@_-2] gets the next to the last field;
@_ is the total array;
at the end of the scan (like AWK) just print the sorted array.
For example to extract the next to the last field of an ascii file separated by "|" and sort them, it can be done with one line: C:\> perl -ane"split/\|/; $l=@_[@_-2];push@r,$l.\"\n\"if$l;END{print sort@r}" bands.txt
works on any unix too.
I find it amazing that back in the mid 1990s, just when Java started to become popular this direction of language design, and maybe greatly improving the concepts, compilers etc. did not take off. The syntax could be cleaner very BASIC like at least, there are so many improvements conceivable but the ideas are great:
split - it is implied that the line is split and the result is in an array called @_.
@_[@_-2] gets the next to the last field;
@_ is the total array;
at the end of the scan (like AWK) just print the sorted array.
Last edited: