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

Re: Need pipe and parameter help

by Todd Chester (Scribe)
on Nov 18, 2016 at 20:33 UTC ( [id://1176113]=note: print w/replies, xml ) Need Help??


in reply to Need pipe and parameter help

Sharma over on comp.lang.perl.misc figured this out for me.
Thank you all for the help.

#!/usr/bin/perl use strict; use warnings; chomp(my $Pipe = ( ! -t \*STDIN ) ? do{local $/; <STDIN>} : q{}) +; print "This was read from the pipe:\n<$Pipe>\n\n"; print "These are the list of parameters:\n<@ARGV>\n"; __END__



$ ReadAPipe3.pl This was read from the pipe: <> These are the list of parameters: <> $ ReadAPipe3.pl 1 2 3 This was read from the pipe: <> These are the list of parameters: <1 2 3> $ echo abc | ReadAPipe3.pl 1 2 3 This was read from the pipe: <abc> These are the list of parameters: <1 2 3> $ (sleep 3; echo abc ) | ReadAPipe3.pl 1 2 3 This was read from the pipe: <abc> These are the list of parameters: <1 2 3> $ echo abc | ReadAPipe3.pl This was read from the pipe: <abc> These are the list of parameters: <> $ sleep 3 | ReadAPipe3.pl 1 2 3 This was read from the pipe: <> These are the list of parameters: <1 2 3>

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-20 02:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found