[Omaha.pm] bad perl - need help - dispatch table

Miller, Scott L (Omaha Networks) scott.l.miller at hp.com
Thu Aug 26 11:01:01 CDT 2004


Oh, I forgot one other trick I like to use.  If you pipe something into
a perl script AND want the routine to parse the input of another file,
well that just doesn't work with the magic spaceship (<>).

You have to do something like this:

   #### process data from STDIN if piped in
   if(! -t) {
      while(<STDIN>) {
         &process_line;
      }
   }
   
   #### Read through the object files (to be given on cmd line)
   if(scalar(@ARGV) > 0) {
      while (<>) {
         &process_line;
      }
   }

Otherwise the (<>) will either ignore <STDIN> because there are filename
on ARGV, or ignore the filenames because it's got stuff to process on
<STDIN>.  It's been too long since I ran into the problem to remember
which...

-Scott



More information about the Omaha-pm mailing list