Mike Singleton wrote:
> I am doing something awry here, the first part of the script doesn't seem to replace 
>all the spaces with commas and strip everything before the date....
> 
> 
> my @files = glob('3D2*.log');
> my @f = split /s+/,$_,9;
>    print OUTF join(',',@f)."\n";
>    close (OUTF);
> open(OUTF,">myfile.csv");
> local @ARGV = @files;
> while (<>) {
>    print OUTF if /$JOBSTART/  || 
>                  /$CONDSTART/ ||
>                  /$JOBEND/    ||
>                  /$CONDEND/   ||
>                  /$JOBCANC/   ||
>                  /$XFER/   ||
>                  /$VOLUSED/;
>    
> }
>    
> close (OUTF);

I hate globbing, so here is an alternative:

use strict;
my $JOBSTART = 'JOBSTART';
my $CONDSTART = 'CONDSTART';
my $JOBEND = 'JOBEND';
my $CONDEND = 'CONDEND';
my $JOBCANC = 'JOBCANC';
my $XFER = 'XFER';
my $VOLUSED = 'VOLUSED';

opendir DIR, '.' or die "opendir: $!";
my @files = grep /^3D2.*\.log$/i, readdir DIR;
closedir DIR;

print "files=@files\n";
open OUT, ">myfile.csv" or die "openCSV: $!";
foreach (@files) {

        print "opening $_\n";
        open IN, $_ or die "open $_: $!";
        while (<IN>) {
                my @f = split /s+/,$_,9;
                print OUT join (',', @f) . "\n" if
          /$JOBSTART|$CONDSTART|$JOBEND|$CONDEND|$JOBCANC|$XFER|$VOLUSED/;
        }
        close IN;
}
close OUT;

__END__



-- 
   ,-/-  __      _  _         $Bill Luebkert   ICQ=162126130
  (_/   /  )    // //       DBE Collectibles   Mailto:[EMAIL PROTECTED]
   / ) /--<  o // //      http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to