Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: string initialization error

by soonix (Abbot)
on Dec 21, 2018 at 14:00 UTC ( #1227560=note: print w/replies, xml ) Need Help??

in reply to string initialization error

the message says the error occured in "line 41". Your code has 8 lines. I assume there are about 37 lines above these 8 lines, and probably some below. The cause of the error lies in the part that you didn't post, or in the way you call your script (e.g. not calling it with the needed parameter(s)) - which you didn't post either.

Replies are listed 'Best First'.
Re^2: string initialization error
by *alexandre* (Acolyte) on Dec 21, 2018 at 22:31 UTC
    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
      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 ); } }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1227560]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2019-06-17 21:05 GMT
Find Nodes?
    Voting Booth?
    Is there a future for codeless software?

    Results (80 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!