Reputation: 649
What will be the output of the following program and Why? is there any significance to symbol table w.r.t to the result?
package Test;
sub func {
print "First instance\n";
}
sub func {
print "Second instance\n";
}
1;
#! /usr/bin/perl
# File: script.pl
use Test;
Test::func();
Upvotes: 0
Views: 200
Reputation: 6309
"Second instance\n"
A package/global variable will have an entry in the symbol table, you can try this to verify:
use Test;
Test::func();
for my $entry ( keys %Test:: )
{
print "$entry\n";
}
Link to reference: http://www252.pair.com/comdog/mastering_perl/Chapters/08.symbol_tables.html
Upvotes: 1