4 ms·
I don't really know a lot about this stuff, but my understanding is that Perl was more or less replaced sed and awk.
by cop359 15y ago
I don't really know a lot about this stuff, but my understanding is that Perl was more or less replaced sed and awk.
- caw 15y agoI code in Perl at my day job, and I still use awk and grep. Sometimes it's quicker to do it in awk than perl, especially when you're doing it in command line and have to figure out quotes. awk -F, '{print $3}' foo | xargs -I{} echo 'command -x -y -z {}' perl -e 'open F, "<foo"; while(<F>) { my($a,$b,$c,@rest) =split /,/; system("command -x -y -z $c"); }' I think I could do the split into an array and then take the third element, but I'm just trying to do an elementary example. When you want to do more things to this argument you necessarily have to grow this, and at one point I got to the point where I started having to escape quotes. That's rather difficult to read when you're just trying to do something quick in the command line and you mismatch a pair.
- ajays 15y agoInstead of opening the file "foo" by hand, you can use Perl's "awk mode" thusly: perl -lane 'system("command -x -y -z $F[2]")' foo
- brendano 15y agoawk (and to a lesser extent sed) is cleaner and easier to remember.