Package declarations and subroutine
$name="out";
$num=1;
package myPackage;
sub welcome {
print "Who is your pal? ";
chomp($name=<STDIN>);
print "Welcome $name!\n";
print "\$num is $num.\n";
print "Where is $main::name?\n\n";
}
package main;
&friend::welcome;
print "main package \$name is $name\n";
print "friend package, Bye ",$friend::name,"\n";
print "Bye $name\n\n";
package anotherPackage;
$name="AAA";
print "Hi $name.\n";
print "$::name and $friend::name\n";
Related examples in the same category