http://qs1969.pair.com?node_id=1227585


in reply to Re: string initialization error
in thread string initialization error

Hi guys, First thx for the interest you are been taking, here's a full cgi sample I've rewrite to bbe simple
#!/usr/bin/perl -w use strict; use warnings; use CGI; my $query = CGI->new ; loadPage (); sub loadPage { my $page = ""; $page = $query->param("page"); if ($page eq 'main') { print "Content-Type: text/html\n\n"; print "main page to load"; }else { print "Content-Type: text/html\n\n"; print "error"; } }
this code work well now, I'm searching on other modules to see what's wrong thx Alexandre Jaquet

Replies are listed 'Best First'.
Re^3: string initialization error (cgi101)
by Anonymous Monk on Dec 21, 2018 at 23:16 UTC
    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 ); } }
    ...