Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > unix pipes to perl scripts

Reply
Thread Tools

unix pipes to perl scripts

 
 
trt.
Guest
Posts: n/a
 
      03-14-2005

Got a problem piping command output to a perl script, in the test below
the loop accepts the piped files but it also interferes with my STDIN!

===test=============================
$ls -1 *.cfg | ./pp
ls -1 *.cfg | ./pp
file: hosts.cfg
file: pseries.cfg

type something : you typed :
===test=============================

I do not get the chance to type something in after "type something"...

Do i have to flush some variable inbetween the foreach loop and
<STDIN>?
Is looping trough <ARGV> or <> the best way to catch piped input?

===code=============================
$cat ./pp
#!/usr/bin/perl

while ( <ARGV> ) {
print "file: $_";
};

print "\ntype something : ";
$answer = <STDIN>;
print "you typed : $answer \n";
===code=============================

thanks!

 
Reply With Quote
 
 
 
 
Michael Abootorab
Guest
Posts: n/a
 
      03-15-2005
how about this

$ls -1 *.cfg | perl -ne '
print "file: $_";
while(<> ){
print "file: $_";
};
print "\ntype something : ";
$answer = <STDIN>;
print "you typed : $answer \n";
'

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is required for perl scripts to run correct when launched from rc scripts on HPUX 11? deanjones7@gmail.com Perl Misc 13 09-10-2007 11:58 AM
Java and UNIX pipes potato Java 3 07-22-2005 07:13 PM
unix pipes to perl scripts trt. Perl Misc 4 03-14-2005 03:40 PM
Integerating Unix pipes with Swing Utilities Ganesh Java 4 01-31-2005 12:14 PM
Perl scripts for Unix on my windows machine Ren Patterson Perl Misc 23 10-17-2003 07:00 PM



Advertisments