in reply to seeking piped STDIO

I was just reading something about something similar to this is the Perl Cookbook. Where you could seek() back to the begining on the perl sciprt and actually parse the script from the script. weird yet none the less, cool.
however I don't think this is what you want to be doing in this case.. I think what you want to do is something similar to what adamsj suggested by rewriting your script to either take command line args as filenames, or "piping" the file names to the script ie:
ls files.* | script.pl OR ./script.pl files.ext files.ext2 files.ext3
or something else to that extent..
be creative, but account for as many cases as you can think of.. if the files are going to be located in the same place and/or named the same thing.. maybe you only want to pass the directory where the files are and/or the file prefix/suffix to open.. that way you can use an opendir(), readdir() and match files with regular expressions so you can have stuff like:
./script.pl -d /my/dir/for/files -f files
and in the script:
.... $defaultdir = "/usual/place/to/look"; $dir = $opt_d; $dir = $defdir unless -e $dir; $defprefix = "files\."; $prefix = $opt_f; $prefix = $defprefix unless $prefix; opendir(LS, $dir) || die "couldn't open dir\n"; while(my $file = readdir(DIR)) { if($file =~ /^$prefix/) { push @FILES,$file; } } ....
then do what adamsj suggested, open each file in @FILES, check the first line, then send the file name or filehandle to the subroutine and have the subroutine open the file or seek to the beginning of the file handle.

just a few ideas..

-brad..

Replies are listed 'Best First'.
Re: Re: seeking piped STDIO
by adamsj (Hermit) on Nov 16, 2000 at 23:29 UTC
    I used to live dangerously--writing scripts that used themselves as data, then destroyed themselves after doing their dirty work. Sounds like illicit activity? Not on your life--just a way to cleanly install something on a massive remote basis when silly rules constrained me to one file, which I could only execute--I couldn't, for instance, send a tarball, pop it open, and then do the install. (Those rules cared about number of files and not actual bandwidth.)