Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^5: How to write a program to read stdin or command line?

by BrowserUk (Pope)
on Oct 03, 2007 at 11:00 UTC ( #642374=note: print w/replies, xml ) Need Help??


in reply to Re^4: How to write a program to read stdin or command line?
in thread How to write a program to read stdin or command line?

With -p, whilst you can conditionally undef $_ to avoid it being printed; if you are also using -l, you will get unwanted blank lines:

C:\test>type junk.txt 1 2 3 4 5 C:\test>perl -nle"$_ & 1 and print" junk.txt 1 3 5 C:\test>perl -ple"$_ & 1 or undef $_ and next" junk.txt 1 3 5

And in fact the next in your example serves no purpose:

C:\test>perl -ple"$_ & 1 or undef $_" junk.txt 1 3 5

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^6: How to write a program to read stdin or command line?
by ikegami (Pope) on Oct 03, 2007 at 13:36 UTC
    Yeah, I was confused, sorry.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://642374]
help
Chatterbox?
[moritz]: like JSON::Schema
[Corion]: ambrus++ # more bugs than lines
[Corion]: That's like "works on my machine" ;-)
[choroba]: I mean, I'd like to say "this path should run this sub, but first it should check the user is authenticated, has the following permissions, and the contents is valid against a given schema
[ambrus]: no, that means I haven't even tried to run it, might not even parse
[ambrus]: so it doesn't work on my machine
[choroba]: i.e. I know JSON::Schema, I'm just curious whether there's a ready solution to plug it into a web service

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2016-12-08 12:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (141 votes). Check out past polls.