Well as a followup to my own email..

This works where the while loop does not, so at least now I've found a way
to pipe the output of the unix find command into my program :)  I'm still
not sure I understand why though...

chomp(@files = <>);

I had also tried:

while (<>) {
        @files = $_;
}

but that had the same problem, so somehow the while loop causes the first
argument to be dropped from the input stream?

>  -----Original Message-----
> From:         Jason Wozniak  
> Sent: Friday, January 31, 2003 3:05 PM
> To:   '[EMAIL PROTECTED]'
> Subject:      Help with input streams
> 
> I am trying to put together a search and replace program that I can string
> together with typical unix shell commands like find, and grep.  However, I
> can't get past the initial read of the files I want to process, using the
> diamond operator.  I lose the first argument in the list every time.  I
> put the below code together for debugging purposes to figure out what's
> going on.
> 
> while (<>) {                                          
>         @files = <STDIN>;                             
> }                                                     
> $count = scalar @files;                               
> print "There are $count files in the process list!\n";
> print @files;                                         
> 
> 
> When I run this with the command:  find /u06 -name glog.log.bak* |
> /export/home/jwozniak/fm.pl
> It drops the first file in the list for output.
> 
> The find command by itself returns 10 files as follows:
> 
> /u06/logs/glog.log.bak.3 
> /u06/logs/glog.log.bak.4 
> /u06/logs/glog.log.bak.1 
> /u06/logs/glog.log.bak.2 
> /u06/logs/glog.log.bak.5 
> /u06/logs/glog.log.bak.6 
> /u06/logs/glog.log.bak.7 
> /u06/logs/glog.log.bak.8 
> /u06/logs/glog.log.bak.9 
> /u06/logs/glog.log.bak.10
> 
> However the output piped to my perl program drops the first line of input
> every time.  For some reason /u06/logs/glog.log.bak.3  does not make it
> into the files array?  Regardless of whether if I pipe it in from the find
> command or simply read the same data in from a file, and instead the
> output from perl is as follows
> 
> There are 9 files in the process list!
> /u06/logs/glog.log.bak.4              
> /u06/logs/glog.log.bak.1              
> /u06/logs/glog.log.bak.2              
> /u06/logs/glog.log.bak.5              
> /u06/logs/glog.log.bak.6              
> /u06/logs/glog.log.bak.7              
> /u06/logs/glog.log.bak.8              
> /u06/logs/glog.log.bak.9              
> /u06/logs/glog.log.bak.10             
> 
> What am I missing?
> 
> Regards,
> 
> Jason Wozniak
> 
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to