Pavanai has asked for the wisdom of the Perl Monks concerning the following question:
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 26Testcase 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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Retain global value across files
by choroba (Cardinal) on Nov 27, 2014 at 17:03 UTC | |
by Anonymous Monk on Nov 28, 2014 at 05:05 UTC | |
|
Re: Retain global value across files
by davido (Cardinal) on Nov 27, 2014 at 18:24 UTC |