Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: CGI redirection

by 7stud (Deacon)
on Jan 18, 2013 at 00:33 UTC ( #1013922=note: print w/ replies, xml ) Need Help??


in reply to CGI redirection

Also, if you find yourself escaping lots of characters inside a string, you are not taking advantage of perl's numerous quoting mechanisms. Look here:

my $html = <<END_OF_HTML; <html> <head><title>Web redirection</title> </head> <body> <form action="redirect.pl" method="post" > <fieldset> <legend>Kindly select a website to visit</legend> <strong>Select a website form the list:</strong> <select name="website"> <option value="www.sedocaonline.com">Sedocaonline.com</option> <option value="http://www.yahoo.co.uk">Yahoo.co.uk</option> <option value="http://www.play.com">play.com</option> </select> <input type="hidden" name="op" value="ds" > <input type="submit" name="submit" value="Browse the web"> </form> </body> </html> END_OF_HTML print $html;

That's called the 'here doc' syntax. Perl also has q{} and qq{}:

use strict; use warnings; use 5.012; my $greeting = 'hello'; my $str1 = q{The lady said $greeting to me.}; my $str2 = qq{The lady said $greeting to me}; say $str1; say $str2; --output:-- The lady said $greeting to me. The lady said hello to me.

q{} is an alternative to single quotes, and qq{} is an alternative to double quotes--and you can use any delimiter you want:

say q['hello' {world}]; say q*hello ["'] world*; --output:-- 'hello' {world} hello ["'] world


Comment on Re: CGI redirection
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2014-09-20 03:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (152 votes), past polls