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

Re: Re: Problem with form submission and redirect

by Arcanum (Sexton)
on Aug 26, 2002 at 17:05 UTC ( [id://192949]=note: print w/replies, xml ) Need Help??


in reply to Re: Problem with form submission and redirect
in thread Problem with form submission and redirect

Thanks for the tips. I was going to use a here document, but I couldn't get it working initially. I didn't realize I needed to wrap it in quotes until I looked at an old script I wrote that made use of a here document.

Having never had any sort of instruction in Perl, I'm not sure of the reason why rows of print statements are to be avoided. Is it simply for readability, or is there a functional advantage?

  • Comment on Re: Re: Problem with form submission and redirect

Replies are listed 'Best First'.
Re (3): Problem with form submission and redirect
by talexb (Chancellor) on Aug 26, 2002 at 18:15 UTC
    Well, compare
    print "Content-type: text/html\n\n"; print "<html>\n"; print "<head>\n"; print "<META http-equiv=\"refresh\" content=\"0; url=http://mail.$ +domain/cgi-bin/qmailadmin\">\n"; print "</head>\n"; print "</html>\n";
    with
    print <<REDIRECT; Content-type: text/html <html> <head> <META http-equiv="refresh" content="0; url=http://mail.$domain/cgi-bin +/qmailadmin> </head> </html> REDIRECT

    I would say that the second one is more readable and more maintainable. And be sure to read merlyn's strong suggestion to use CGI.pm for this particular application, instead of the code above.

    --t. alex
    but my friends call me T.

      Use CGI redirect for cleaner code. print "Location: /mail.$domain/cgi-bin/qmailadmin\n\n"; See Merlyn's post (Randal Schwartz) above. Rather than either example below shown previously. print "Content-type: text/html\n\n"; print "<html>\n"; print "<head>\n"; print "<META http-equiv=\"refresh\" content=\"0; url=http://mail.$ +domain/cgi-bin/qmailadmin\">\n"; print "</head>\n"; print "</html>\n"; print <<REDIRECT; Content-type: text/html <html> <head> <META http-equiv="refresh" content="0; url=http://mail.$domain/cgi-bin +/qmailadmin> </head> </html> REDIRECT
      Just an observation, from a lowly peasant :) HEREDOCS seem to break up the flow when indentation is thrown in the mix..
      Compare NORMAL with a bit of creative indentation ------ sub level1{ if ($level2){ print "Content-type: text/html \n\n". "<html> \n". "<head> \n". "<META http-equiv=\"refresh\" "content=\"0; ". "url=http://mail.$+domain/cgi-bin/qmailadmin\"> \n". "</head> \n". "</html> \n"; } } with HEREDOC ------- sub level1{ if($level2){ print <<REDIRECT; Content-type: text/html <html> <head> <META http-equiv="refresh" content="0; url=http://mail.$domain/cgi-bin +/qmailadmin> </head> </html> REDIRECT } }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-19 16:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found