Hi Monks,
I'm trying out with a script that calls module which stores a hash of country information. The following is my sample code:
#script.pl
#!/usr/local/bin/perl
#use strict;
use CGI qw(:standard);
eval {
($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1");
require 5.001;
require "module.pm";
};
if ($@) {
die("Error including libraries: $@\n");
}
msg();
sub msg {
print "Content-type: text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<title>Country</title>\n";
print "</head>\n";
print "<body bgcolor=\"#FFFFFF\" text=\"#000000\">";
print "$country{'af'}<br>\n";
print "</body>\n</html>\n";
}
# module.pm
# module.pm
%country = (
af => 'afghanistan',
ao => 'angola',
ar => 'argentina',
at => 'austria',
au => 'australia',
bd => 'bangladesh',
be => 'belgium',
bg => 'bulgaria',
);
When I enable 'strict', the code doesn't work. I tried to declare the hash %country with 'my' but it doesn't help. I figured it's something to do with Exporter but I'm not quite sure how that's done.
Please advise and thanks in anticipation =)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.