SPUG:Best One-Liners and Scripts for UNIX
SPUG-list-owner
tim at consultix-inc.com
Fri Apr 18 11:58:15 CDT 2003
On Fri, Apr 18, 2003 at 06:33:02AM -0700, Brian Hatch wrote:
>
>
> > Ouch! That's too complicated for my "Minimal Perl" tastes.
>
> I just gave you my starting point - of course we can
> play with things.
I'm not criticizing, just exploring simpler approaches.
> > How about the following as a one-liner to type directly to the shell,
> > perl -wlna -e 'print "@F[3,1,2]"' file
>
> I use perl one liners on the command line all the time. But
> when I use one too much, then I put it in a function so I don't
> need to any more. That's the whole point.
Agreed.
> > unshift @F, "(No zeroth field! first is #1)";
>
> Are you nuts? That was the whole point of using perl! Of course
> the first field should be field #0. Anything else is unperlish.
Huh???
My point was that it's more *Human-ish* to let the user specify the
first field as field #1 (like Awk does), regardless of what Perl uses
internally. TMTOWTDI!
> I also wanted the use of the '..' operator - you're not going
> to take that away, are you?.
>
> Brian Hatch Language, it's a virus.
I'm not trying to take *anything* away from you, just improvising
alternative approaches that bring out other trade-offs, that people
might find interesting. Your solution (which I can't see right now,
but I think I remember the essentials) had the benefit of being
pre-processed by a shell, so the dots in 1..2 would be seen in the
initial parsing of the Perl program. With the pure-perl approach
I've taken, I believe an eval would be required to handle the range
specifier (since it resides in a variable), and I decided to draw
the line there.
-Tim
*------------------------------------------------------------*
| Tim Maher (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX |
| CEO, JAWCAR ("Just Another White Camel Award Recipient") |
| tim at Consultix-Inc.Com TeachMeUnix.Com TeachMePerl.Com |
*+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-*
| Watch for my Book: "Minimal Perl for Shell Programmers" |
*------------------------------------------------------------*
----- End forwarded message -----
--
-Tim
*------------------------------------------------------------*
| Tim Maher (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX |
| CEO, JAWCAR ("Just Another White Camel Award Recipient") |
| tim at Consultix-Inc.Com TeachMeUnix.Com TeachMePerl.Com |
*+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-*
| Watch for my Book: "Minimal Perl for Shell Programmers" |
*------------------------------------------------------------*
More information about the spug-list
mailing list