> Matt,
> 
> A couple of things here. first, you don't perform any modification of
> $culist, but the strings in $culist don't appear unmodified in the log
> file. the string perl reads into $_ from a file like you're example is
> e.g. "SUN9-GT:\n". The string in the log file, though, is just
> "SUN9-GT". try something like '$culist =~ tr/:\n//' or
> 
>     while (my $culist = <CULIST>) {
>         chomp $culist;
>         $culist =~ s/(\w+):/$1/;
>         # .... the rest of your code
>     }
> 
> Next, grep(). grep takes a list and returns the elements of the list
> that match. the 'while (<>)' construct, though, only reads a line at
> time, and you don't seem to be splitting into an array. That makes
> grep superfluous. All you need here is:
> 
>     while (<SEPTEMBER>) {
>         chomp;
>         print CU_OUTPUT "$_\n\n" if /$culist/;
>         print "$_\n\n";
>     }
> 
> 
> HTH,
> 
> -- jay

First, thanks for your input Jay, Rob, Lawrence

Jay,

I tried your script.  What happens is it gets through the first
iteration of the script and copies the appropriate lines to the new log
file.  But each subsequent iteration is skipped over.

This is what I have:


use warnings;
use strict;
open CULIST, "/root/syslog_stuff/CULIST3.txt" or die $!;

open SEPTEMBER, "/var/log/log_netscreen_sep" or die $!;

while (<CULIST>) {
chomp (my $culist = $_);
print "$culist\n";
open CU_OUTPUT,">> /root/syslog_stuff/monthly_logs/sep2/$culist"or die
$!;

        while (<SEPTEMBER>) {
               chomp;
                print CU_OUTPUT "$_\n\n" if /$culist/;
        #       print "$_\n\n"; 
        }

}

The script goes through each $culist (shown by printing the each
variable) - but it looks like it's skipping over the "while
(<SEPTEMBER>)" part for the rest of the $culist.  Any ideas?

Matt


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to