Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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

by LanX (Saint)
on Aug 28, 2020 at 10:56 UTC ( [id://11121141]=note: print w/replies, xml ) Need Help??


in reply to Re^5: 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

> Awk's greatest strength and greatest limitation is the implicit outer loop

Are you aware about Perl's command switches?

If not, just have a look at perlrun and search for "awk".

> Perl needs for startup/shutdown overhead.

Probably, but do I want to install awk and sed on Windows?

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

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

Replies are listed 'Best First'.
Re^7: Split tab-separated file into separate files, based on column name (open on demand)
by jcb (Parson) on Aug 28, 2020 at 23:23 UTC
    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. :-)

      > 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11121141]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-16 18:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found