Create strings without escape characters using uri_unescape
#!/usr/bin/perl -T use strict; use URI::Escape; use CGI qw/:standard/; my $unsafestring = "\$5/[3454]/this is a windows filename.asp"; my $safestring = uri_escape($unsafestring); my $unescstring = uri_unescape($safestring); print header, start_html("Making URLs Safe Is Our Business"), p("The string that is unsafe for a URL is: $unsafestring\n"), p("When fed through the url_escape() function it becomes: $safestring\n"), p("When the escaped string is unescaped, it becomes: $unescstring\n"), end_html; exit;
Getting a Safe String with uri_escape
#!/usr/bin/perl -T use strict; use URI::Escape; use CGI qw/:standard/; my $unsafestring = "\$5/[3454]/this is a windows filename.asp"; my $safestring = uri_escape($unsafestring); print header, start_html("Making URLs Safe Is Our Business"), p("The string that is unsafe for a URL is: $unsafestring\n"), p("When fed through the url_escape() function it becomes: $safestring\n"), end_html; exit;
Writing to an Alternate Log File using CGI::Carp
#!/usr/bin/perl -T use strict; use CGI qw/:standard/; BEGIN { use CGI::Carp qw(carpout); open (ERRORLOG, '>>', '/logs/cgierrors1234.log') or die("Unable to open log file: $!\n"); carpout('ERRORLOG'); } print header, start_html("Testing CGI Carp"); warn ("This is a test warning"); print p("Hello, this is a test, check the logfile"), end_html; exit;
Using set_message with CGI::Carp
#!/usr/bin/perl -T use strict; use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser set_message); set_message("This is a better message for the end."); print header, start_html("Testing CGI Carp"); die ("This is a test die"); print end_html; exit;
Sending an Error to the Browser with CGI::Carp
#!/usr/bin/perl -T use strict; use CGI qw/:standard/; use CGI::Carp qw/fatalsToBrowser/; print header, start_html("Testing CGI Carp"); die ("This is a test die"); print end_html; exit;
