#!/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>
In reply to Re: Need pipe and parameter help
by Todd Chester
in thread Need pipe and parameter help
by Todd Chester
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |