Note: The archives category content is an automatically generated focus channel and does not neccessarily reflect the opinions of this blog. No responsibility is taken for the external links presented here, follow at your own discretion.
The archives content is never scraped from sites - but an abstract obtained from search engines.
| Problem |
Solution |
Example |
Reference |
Recommended |
Easy. Perl comes with some excellent binaries, which will convert AWK or SED scripts to Perl. Excellent tool for learning Perl too!!
|
|
| Problem |
Solution |
Example |
Reference |
Recommended |
To convert from AWK to Perl: a2p awkscript To convert from Sed to Perl: s2p awkscript $ date | awk ' { print $(NF-1) } ' WST $ cat > awkscript { print $(NF-1) } $ date | awk -f awkscript WST $ a2p awkscript #!/usr/bin/perl eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' if $running_under_some_shell; # this emulates #! processing on NIH machines. # (remove #! line above if indigestible) eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift; # process any FOO=bar switches $[ = 1; # set array base to 1 $, = ' '; # set output field separator $\ = "\n"; # set output record separator while () { chomp; # strip record separator @Fld = split(' ', $_, 9999); print $Fld[$#Fld - 1]; } $ a2p awkscript > perlscript $ date | ./perlscript WST
|
Leave a Reply