print "\nHello, myModule.pl is running now! Called by $PROGRAM_NAME "; sub trim { my $string = shift; $string =~ s/^\s+//; $string =~ s/\s+$//; return $string; } # Left trim function to remove leading whitespace sub ltrim { my $string = shift; $string =~ s/^\s+//; return $string; } # Right trim function to remove trailing whitespace sub rtrim { my $string = shift; $string =~ s/\s+$//; return $string; } # This is for demonstration purpose only: my $PI = 3.141; sub value_of_pi { return $PI; } non_existent_sub(); #### #!/home/myhomedrive/opt/perl/bin/perl use strict; use warnings; my $PROGRAM_NAME = "Test"; # The following line reads the entire myModule.pl file and executes it using eval(): @ARGV = "myModule.pl"; eval(join('',<>)); my $string = " ll "; $string = trim( $string ); print "\n|$string|\n"; print "\n", value_of_pi();