Almost, you pass arguments to subroutines, not work on globals. see
cgi101/
Re: Object Identifier? (red flags, more subs)
#!/usr/bin/perl --
use strict;
use warnings;
use CGI;
Main( @ARGV );
exit( 0 );
sub Main {
my $q = CGI->new;
my( $headers, $body ) = loadPage( $q );
print $headers, $body;
}
sub loadPage {
my( $query ) = @_;
if( authenticate( $q ) ){
my $page = $q->page || 'default';
return ThisPage( $pms, $q ) if $page eq 'thisone';
return ThatPage( $pms, $q ) if $page eq 'thatone';
return DefaultPage( $pms, $q );
} else {
return UnauthorizedPage( $pqms, $q );
}
}
...