in reply to Re^6: Split tab-separated file into separate files, based on column name (open on demand)
in thread Split tab-separated file into separate files, based on column name

Are you aware about Perl's command switches?

Yes, but the optional implicit outer loops in Perl are different from the implicit outer loop in Awk — Awk's syntax is built around its implicit outer loop, using PATTERN-RULE pairs, while Perl's implicit outer loops are purely for convenience. I have always just written an outer loop explicitly even in one-liners.

do I want to install awk and sed on Windows?

Unless you already have them, perhaps from Cygwin, possibly not. That is a fair point — on Windows, the Perl startup/shutdown overhead is (probably still) dwarfed by the system startup/shutdown overhead for each process. I kicked Windows out of my personal LAN years ago, though, so I usually do not think to consider its inadequacies. :-)

  • Comment on Re^7: Split tab-separated file into separate files, based on column name (open on demand)

Replies are listed 'Best First'.
Re^8: Split tab-separated file into separate files, based on column name (open on demand)
by LanX (Saint) on Aug 29, 2020 at 13:56 UTC
    > Yes, but the optional implicit outer loops in Perl are different from the implicit outer loop in Awk — Awk's syntax is built around its implicit outer loop, using PATTERN-RULE pairs, while Perl's implicit outer loops are purely for convenience. I have always just written an outer loop explicitly even in one-liners.

    I have trouble understanding what you mean.

    AFAICS are awk's PATTERN-RULES nothing more than if(PATTERN) { RULE } in Perl, plus some special defaults (no Rule means print)

    Could you give an example where perl -n fails to allow the same semantic like in awk?

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      The semantics are the same but the syntax is different and the input range operator in Awk only works in pattern syntax; Perl's equivalent .. and ... operators work anywhere.

      The Awk syntax is more elegant for some problems — and completely unusable for most problems better solved in Perl.