I want to include some modules with a small script which I've done.
It reads a certain XML file on the net which contains server status
reports and prints out niceley formatted HTML. I've decided that I am
going release it to the public if the script comes out nice.
Now two questions arrise since I want to include not-so-common Modules with the script
(UBB has MIME:Lite included for example) in case the webmaster can't install Modules himself.
1) Is it perfectly legal to include these Modules with the script (since they can be found on CPAN)?
2) I thought of including a Modules subdirectory (with furher subdirectories) with the script. As you can see in my code example I
use FindBin to get the path of the script and then load the Modules from the subdirectory. While this
works fine I get an "Undefined subroutine &main::get called at script.pl" error.
When I replace the
my $tree = get ($xml_path);with
my $tree = LWP::Simple -> get ($xml_path);that works
but replacing it like this doesn't work for the XML::Simple modules because I get a
"Can't use string ("XML::Simple") as a HASH ref while "strict refs" in use at Modules/XML/Simple.pm 494" error".
What can be done to overcome this problem? Or do I have to use a different XML parser?
#!/usr/local/bin/perl
use strict;
use FindBin qw($Bin);
use lib "$Bin" . "/Modules";
use Modules::LWP::Simple;
use Modules::XML::Simple;
use Modules::HTML::Template;
sub generate_reports
{
my $xmlfile = get ($xml_path);
my $tree = XMLin ($xmlfile);
...
}
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.