Stories
Slash Boxes
Comments

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Robrt (1414)

Robrt
  (email not shown publicly)

robert at perl dot org

Journal of Robrt (1414)

Monday August 04, 2003
07:12 PM

Shell Golf

[ #13906 ]

I played shell golf with myself today. (I won.)

I started with
echo $PATH | perl -F: -lane'$,="\n"; print @F'
and Ask intervened with
perl -e'print join"\n",split(/:/,$ENV{PATH}),""'
claiming it was "the same length and is using more common idioms.". I noted that his was a lot more typing and punctuation, and mine is mostly whitespace.

I shifted into Awk for a few cycles:
echo $PATH | awk 'BEGIN{RS=":"} {print}'
echo $PATH | awk -vRS=: '{print}'

but what I really wanted was sed. I settled with perl
echo $PATH | perl -pe's/:/\n/g'
after determining that tcsh was breaking sed.

But..
echo $PATH | tr : '\n'
I win.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.