# Q.pl - mainline code use Q2 qw($myfile func1 $SM_HDR_REC); # ---- printf("\$Q2::myfile: >$Q2::myfile<\n"); printf("\$Q2::myport: >$Q2::myport<\n"); # Not exported but still # usable by fully-specifying printf("\$myfile: >$myfile<\n"); # Ok 'coz it's exported printf("\$myport: >$myport<\n"); # Unknown 'coz not exported printf("SM_HDR_REC: >$SM_HDR_REC<\n"); # Declared 'our' in Q2.pm # ---- $buf = "test_string"; printf("\nFn call into temp var:\n"); printf("String before: %s\n", $buf); $newbuf = func1($buf); # Works! printf("String after: %s\n\n", $newbuf); $buf = "test_string"; printf("Fn call only:\n"); printf("String before: %s\n", $buf); printf("String after: %s\n\n", func1($buf)); # Doesn't work!? # Q2.pm - module code package Q2; use strict; use Exporter; # ---- use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = 1.00; @ISA = qw(Exporter); @EXPORT = (); @EXPORT_OK = qw($myfile &func1 &func2 $SM_HDR_REC); %EXPORT_TAGS = (DEFAULT => [qw(&func1)], all => [qw(&func1 func2 $myfile)]); # ---- use vars qw($myfile $myport); $myfile = 'FRED.DAT'; # Used locally and exported (above) $myport = "OPA0:"; # Used locally but not exported # ---- our $SM_HDR_REC = "HDR"; # ---- sub func1 { return reverse @_ } sub func2 { return map{ uc }@_ } END { }; 1;