i have 2 files A and B. From A, am trying to call a sub routine defined in B

code snippet A

 verify($fh, 'host', 'state', 'testname');

code snippet in B

sub verify { my $fh = shift; my $routes = 375000; my $inet0_total = 3436701; my $inet0_active = 498151; my $inet6_total = 115803; my $pass_count = 1; our $count_adj = 0; our $count_bfd = 0; our $tc_count = 1; ............... $tc_count = $tc_count + 1;

verify subroutine is called in file A at each testcase s, hence the tc_count should also be incremented. I defined tc_count as global using "our" hoping that tc_count will increment each time when the testcases are executed. But tc_count always shows as 1 for any testcases. Is there a way to retain the tc_count to its current value(after each increment), when the the subroutine verify is called from file A

here is the output after the execution for reference

.

Testcase 1: Disable the process in the router

********************************************************** Verify ISIS adjacency(show isis adjacencies) ---------------------------------------- Interface System L State Hold (secs) SNPA ae1.0 paisa 2 Up 26

Testcase 1: Enable the process in the router

********************************************************** Verify ISIS adjacency(show isis adjacencies) ---------------------------------------- Interface System L State Hold (secs) SNPA ae1.0 paisa 2 Up


In reply to Retain global value across files by Pavanai

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.