1.
qq{ ... } is like " ... "
qw{ ... } is like split(' ', q{STRING});
see Quote and Quote-like Operators in
perldoc perlop
2.
$fullname will be set equal to $cookie{fullname} is it is true (defined and not empty or "0") else to an empty string
3.
perldoc CGI
AUTOESCAPING HTML
By default, all HTML that is emitted by the form-generating functions
is passed through a function called escapeHTML():
$escaped_string = escapeHTML("unescaped string");
Escape HTML formatting characters in a string.
Provided that you have specified a character set of ISO-8859-1 (the
default), the standard HTML escaping rules will be used. The "<" char-
acter becomes "<", ">" becomes ">", "&" becomes "&", and the
quote character becomes """. In addition, the hexadecimal 0x8b
and 0x9b characters, which many windows-based browsers interpret as the
left and right angle-bracket characters, are replaced by their numeric
HTML entities ("‹" and "›"). If you manually change the
charset, either by calling the charset() method explicitly or by pass-
ing a -charset argument to header(), then all characters will be
replaced by their numeric entities, since CGI.pm has no lookup table
for all the possible encodings.
The automatic escaping does not apply to other shortcuts, such as h1().
You should call escapeHTML() yourself on untrusted data in order to
protect your pages against nasty tricks that people may enter into
guestbooks, etc.. To change the character set, use charset(). To turn
autoescaping off completely, use autoescape():
$charset = charset([$charset]);
Get or set the current character set.
$flag = autoEscape([$flag]);
Get or set the value of the autoescape flag.
5.
CGI::Carp qw(warningsToBrowser(1) fatalsToBrowser);
should be
CGI::Carp qw(warningsToBrowser fatalsToBrowser);
...
warningsToBrowser(1);
perldoc CGI::Carp
MAKING PERL ERRORS APPEAR IN THE BROWSER WINDOW
If you want to send fatal (die, confess) errors to the browser, ask to
import the special "fatalsToBrowser" subroutine:
use CGI::Carp qw(fatalsToBrowser);
die "Bad error here";
Fatal errors will now be echoed to the browser as well as to the log.
CGI::Carp arranges to send a minimal HTTP header to the browser so that
even errors that occur in the early compile phase will be seen. Nonfa-
tal errors will still be directed to the log file only (unless redi-
rected with carpout).
6.
perldoc DBI
"finish"
$rc = $sth->finish;
Indicate that no more data will be fetched from this statement han-
dle before it is either executed again or destroyed. The "finish"
method is rarely needed, and frequently overused, but can sometimes
be helpful in a few very specific situations to allow the server to
free up resources (such as sort buffers).
When all the data has been fetched from a "SELECT" statement, the
driver should automatically call "finish" for you. So you should
not normally need to call it explicitly except when you know that
you've not fetched all the data from a statement handle. The most
common example is when you only want to fetch one row, but in that
case the "selectrow_*" methods are usually better anyway. Adding
calls to "finish" after each fetch loop is a common mistake, don't
do it, it can mask genuine problems like uncaught fetch errors.
Consider a query like:
SELECT foo FROM table WHERE bar=? ORDER BY foo
where you want to select just the first (smallest) "foo" value from
a very large table. When executed, the database server will have to
use temporary buffer space to store the sorted rows. If, after exe-
cuting the handle and selecting one row, the handle won't be re-
executed for some time and won't be destroyed, the "finish" method
can be used to tell the server that the buffer space can be freed.
Calling "finish" resets the "Active" attribute for the statement.
It may also make some statement handle attributes (such as "NAME"
and "TYPE") unavailable if they have not already been accessed (and
thus cached).
The "finish" method does not affect the transaction status of the
database connection. It has nothing to do with transactions. It's
mostly an internal "housekeeping" method that is rarely needed.
See also "disconnect" and the "Active" attribute.
The "finish" method should have been called "discard_pending_rows".
MAKING WARNINGS APPEAR AS HTML COMMENTS
It is now also possible to make non-fatal errors appear as HTML com-
ments embedded in the output of your program. To enable this feature,
export the new "warningsToBrowser" subroutine. Since sending warnings
to the browser before the HTTP headers have been sent would cause an
error, any warnings are stored in an internal buffer until you call the
warningsToBrowser() subroutine with a true argument:
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
use CGI qw(:standard);
print header();
warningsToBrowser(1);
You may also give a false argument to warningsToBrowser() to prevent
warnings from being sent to the browser while you are printing some
content where HTML comments are not allowed:
warningsToBrowser(0); # disable warnings
print "<script type=\"text/javascript\"><
print_some_javascript_code
print "//--></script>\n";
warningsToBrowser(1); # re-enable warnings
Note: In this respect warningsToBrowser() differs fundamentally from
fatalsToBrowser(), which you should never call yourself!
Main Topics
Browse All Topics





by: inq123Posted on 2005-08-30 at 11:47:17ID: 14787765
Hi jedistar,
If this is some homework or test questions I don't think any of us should help you (read the EE rules). But if it's not, plenty here could give you help.
Cheers!