hi monk, okok here is the code i wrote. i didnt put here at first because i just want to know the algorithm on the flow . btw, my code is pretty crude so hope do not mind on it.
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;
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)

In reply to Re^2: print content of array individually after parsing multiple input files by teddy6507
in thread print content of array individually after parsing multiple input files by teddy6507

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.