Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: what's this loo code?

by BrowserUk (Pope)
on Feb 04, 2003 at 19:04 UTC ( #232622=note: print w/replies, xml ) Need Help??


in reply to what's this loo code?

If you just want the line count (no slurping).

perl -ne"}{die" file

If you want the filenames too

perl -ne"}{die$ARGV" *


Examine what is said, not who speaks.

The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.

Replies are listed 'Best First'.
Re: Re: what's this loo code?
by Anonymous Monk on Feb 06, 2003 at 15:07 UTC
    that's interesting. how does that '}{die' thing work ? why doesn't perl complain of mismatched braces or something

      Take a look at the documentation for the -p and -n switches in perlrun. In prasee er...short, it says

      -p causes Perl to assume the following loop around your program, which ma +kes it iterate over filename arguments somewhat like sed: LINE:while (<>) { # your program goes here } continue { print or die "-p destination: $!\n"; }

      If you substitute the 'program' eg. "}{die" where the comment above says " your program goes here", then you willl see how the thing works.


      Examine what is said, not who speaks.

      The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://232622]
help
Chatterbox?
[CPUlidster]: 20yrs since I visited.
LanX is sure Louvre is going to move to Glasgow after brexit
[ambrus]: marto: http://www. irregularwebcomic. net/3498.html and http://www. irregularwebcomic. net/3549.html
[ambrus]: the annotation mentions Brisbane as even worse, and I add Debrecen
[marto]: :)
[ambrus]: robby: dunno, I would like to visit London some time, although there are other places I'd like to visit more
[marto]: "Okay, sure, there are in fact museums and art galleries and other culturally enlightened things to do in Glasgow, but that wouldn't have made a funny comic"

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (11)
As of 2017-12-15 11:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (431 votes). Check out past polls.

    Notices?