Thanks for your prompt response
In my earlier post I gave simplified code, where actual function is explained in comment (#). Here is original code.

The output of two calls as follows:

PK_start : Sheet0 : 0, 0, 0, 0, 0
PK_end : Sheet0 : 5 : 17 : 82 : 0 : 0
PK_start : Sheet1 : 8, 21, 82, 0, 0
PK_start : Sheet2 : 0, 0, 82, 0, 0
PK_final : 0, 0, 82, 0, 0
PK_return : 0, 0, 82, 0, 0
APB2DCR_vPlan.ann.xml : 82
PK_start : Sheet0 : 0, 0, 82, 0, 0
PK_end : Sheet0 : 5 : 17 : 78 : 0 : 0
PK_start : Sheet1 : 8, 21, 78, 0, 0
PK_start : Sheet2 : 0, 0, 78, 0, 0
PK_final : 0, 0, 78, 0, 0
PK_return : 0, 0, 0, 0, 0
APB2DCR_vPlan.pass.ann.xml : 0
Please note return value of 3rd variable

sub getFuncCovSummary($) { my ($reportFile) = @_; my $func = 0; my $compl = 0; my $group = 0; my $assert = 0; my $ftest = 0; my $targetSheet = ""; my $col = 0; my $row = 0; my $hvp_col = 0; my $grp_col = 0; my $ass_col = 0; my $tst_col = 0; my $plan_row = 0; my $isData = 0; my $isComment = 0; my $mergeAcross = 0; my $mergeDown = 0; my @str = (); my $parser = new XML::Parser ( Handlers => { Start => \&hdl_start +, End => \&hdl_end, Char => \&hdl_char, Default => \&hdl_def, Final => \&hdl_final +, }); $parser->parsefile( $reportFile ); # The Handlers sub hdl_start{ my ($p, $elt, %atts) = @_; return unless (($elt eq 'Worksheet') || ($elt eq 'Row') || ($elt eq 'Cell') || ($elt eq 'Comment') || ($elt eq 'Data') || ($elt eq 'ss:Data')); if ($elt eq 'Worksheet') { if ($atts{'ss:Name'} =~ /^(\d)_/) {$targetSheet = "Sheet$1";} print "PK_start : $targetSheet : $row, $col, $group, $assert, + $ftest<br>"; $row = 0; $col = 0; } return unless $targetSheet eq "Sheet0"; if ($elt eq 'Row') { $row++; $col = 0;} if ($elt eq 'Cell') { $col = $col + 1 + $mergeAcross; if ($atts{'ss:Index'} > 0) { $col = $atts{'ss:Index'};} if ($atts{'ss:MergeAcross'} > 0) {$mergeAcross = $atts{'ss:Me +rgeAcross'};} else {$mergeAcross = 0;} if ($atts{'ss:MergeDown'} > 0) {$mergeDown = $atts{'ss:MergeD +own'};} else {$mergeDown = 0;} } if ($elt eq 'Comment') { $isComment = 1;} if (($elt eq 'Data') || ($elt eq 'ss:Data')) { @str = (); $isDat +a = 1;} } sub hdl_end{ my ($p, $elt) = @_; return unless $targetSheet eq "Sheet0"; return unless (($elt eq 'Comment') || ($elt eq 'Data') || ($elt eq 'ss:Data')); if ($elt eq 'Comment') { $isComment = 0;} if (($elt eq 'Data') || ($elt eq 'ss:Data')) { if (!$isComment) { my $p = 0; my $str = join("", @str); if ($str =~ /^hvp\s+plan/) { $hvp_col = $col; } if ($str =~ /^value\w+\.Group/) { $grp_col = $col; } if ($str =~ /^value\w+\.Assert/) { $ass_col = $col; } if ($str =~ /^value\w+\.test/) { $tst_col = $col; } if (($col == $hvp_col) && ($str =~ /^plan/)) { $plan_row += $row; } if (($row == $plan_row) && ($col == $grp_col)) { $group = + sprintf("%0.f",$str*100); $p = 1;} if (($row == $plan_row) && ($col == $ass_col)) { $assert = + sprintf("%0.f",$str*100); $p = 1;} if (($row == $plan_row) && ($col == $tst_col)) { $ftest = + $str; $p = 1;} if ($p) {print "PK_end : $targetSheet : $row : $col : $gro +up : $assert : $ftest<br>";} } $isData = 0; } } sub hdl_char { my ($p, $str) = @_; return unless $targetSheet eq "Sheet0"; return unless ($isData && !$isComment); push @str, $str; } sub hdl_def { } sub hdl_final {print "PK_final : $func, $compl, $group, $assert, $f +test<br>"; } print "PK_return : $func, $compl, $group, $assert, $ftest<br>"; return ($func, $compl, $group, $assert, $ftest); }# getFuncCovSummary

In reply to Re^2: scope of variable by priyo
in thread scope of variable by priyo

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.