in reply to Re: print content of array individually after parsing multiple input files
in thread print content of array individually after parsing multiple input files
as you can see , after i print out $error_cellname or $error_flow , all the element will be treated as single element (due to the way i code my main code). i would like to print out the element individually so that i can produce the output i desired(as in my first post)if (exists $args{dir}) { if(-e $args{dir}) { $directory =$args{dir}; { print "Path: $directory\n\n"; } } else { print "-E- the dir does not exist $args{dir}\n"; exit; } } opendir (DIR , "$directory") || die "Cannot open $directory\n"; chdir($directory); $cmd = "ls -t"; chomp ( @files = grep { /log.sum/} `$cmd` ); #print "@files\n"; $flag_flow = 0 ; $flag_tool = 0 ; print "Script version : v1\n\n"; print "Timestamp Cell Status\t Flow\t\t\t + # Errors\t # Warnings\n"; print "========= ====== ====== ====== + ========= ==========\n"; foreach (@files) { if(/(\S+)\.(\S+).iss.log.sum/) { $cellname = $1; } @full = "$directory/"."$_"; foreach my $files (@full) { open INFILE , "<$files" ; open OUTPUT , ">>result.txt" ; my @lines = <INFILE>; my $timestamp = ctime(stat($files)->mtime); my $time = substr($timestamp , 4 , -8); foreach (@lines) { if (/Status\s+Flow/) { $flag_flow = 1; } if($flag_flow) { next if (/====/); if (/^(clean|DIRTY)\s+(\S+)\s+(\S+)\s+(\S+)/) { $data{$a}{Status} = $1; $data{$a}{Flow} = $2; $data{$a}{Errors} = $3; $data{$a}{Warnings} = $4; push @array , $_; #print "$time $cellname $_"; foreach $array (keys %data) { #@summary ="$time\t $cellname $data{$array}{Status} +\t $data{$array}{Flow}\t $data{$array}{Errors}\t\t $data{ +$array}{Warnings}\n"; print "$time\t $cellname $data{$array}{Status}\t $d +ata{$array}{Flow}\t $data{$array}{Errors}\t\t $data{$arra +y}{Warnings}\n"; } } @array = (); } if(/^\s*$/) { $flag_flow = 0 ; } if(/See\s+\$PDSLOGS\/(\S+)\.(\S+)\.icv/) { $error_cellname = $1; $error_flow = $2; #print"$_\n"; #push @match , "cell is $error_cellname , flow is $error_ +flow\n" ; print "CELL = $error_cellname , FLOW = $error_flow\n"; print "===========================================\n"; $error_count = 1; } elsif(/PLAYERR Files Created/) { $error_count = 0; } elsif($error_count) { #push (@err , $_); print "$_"; } } close INFILE ; } } exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: print content of array individually after parsing multiple input files
by Anonymous Monk on Dec 10, 2014 at 20:16 UTC |