in reply to output issue....

Reason is that you are reading input files by lines (the s in reqex is useless) and do the print in if statement for reqex. So even if it matches what you need it does not print the rest of lines because reqex won't match for them.

I would suggest something like that (not tested):
my $c_file = "NO MATCH"; while (<$hfile>) { my $line = $_; if ($line =~ /[DWEM]\s+.*?\s+(?:c|cm|M)\:($input_pid)\s+([^\.]+\.c ++)/s) { $c_file = $2; my $pid = $1; } if($input_string eq $c_file) { #check with input string print $ofile "$line\n"; #write the output in a output file } }

Regards,
s++ą  ł˝ ął. Ş ş şą Żľ ľą˛ş ą ŻĽąş.}++y~-~?-{~/s**$_*ee

Replies are listed 'Best First'.
Re^2: output issue....
by oko1 (Deacon) on Nov 28, 2008 at 20:03 UTC

    "Not tested" is, perhaps, a very kind way of putting it. You may have intended to match both the filename and the PID, but you failed to do the latter anywhere in the code. In addition, you're comparing '$c_file' against a non-existent variable called '$input_string'. Last of all, even if you had checked both the filename and the PID against reasonable values, you'd continue to print lines until you had another successful match - which may not be the right thing to do.

    Update Modified phrasing.


    --
    "Language shapes the way we think, and determines what we can think about."
    -- B. L. Whorf