unix pipes to perl scripts

From: trt. (therealtroll_at_yahoo.com)
Date: 03/14/05

  • Next message: vbhelpski_at_yahoo.com: "installing perl on usb flash drive"
    Date: 14 Mar 2005 02:33:53 -0800
    
    

    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!


  • Next message: vbhelpski_at_yahoo.com: "installing perl on usb flash drive"

    Relevant Pages

    • unix pipes to perl scripts
      ... the loop accepts the piped files but it also interferes with my STDIN! ...
      (comp.lang.perl.misc)
    • Re: unix pipes to perl scripts
      ... > 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! ...
      (comp.lang.perl.misc)
    • Re: unix pipes to perl scripts
      ... > the loop accepts the piped files but it also interferes with my STDIN! ... of course this interferes with your STDIN. ... file (which happens when ls -l *.cfg is finished). ...
      (comp.lang.perl.misc)
    • Re: Gracefully stopping an infinite loop after a particular keyboard input
      ... Talking about case 1, where user inputs Q, stdin will keep ... waiting for some input from keyboard and hence will not start the loop ... I should press Qto stop the script, ... proc do_stuff { ...
      (comp.lang.tcl)
    • Re: Which kind of loop do I use, do or while?
      ... FILE *fp = stdin; ... The alternative method would be not to enter the loop if there are no ... process("standard input", stdin, flags) ... the first iteration might be ...
      (comp.programming)