I'm trying to create my first perl module and I have zero knowledge of what I'm trying to do.
I want to make it simple but something I'll likely use, so I decided on a meta tag parser. The module will use LWP::Simple and parse a given $url and strip ALL meta content into a hash then export the hash into the script so the admin/script user can do whatever the heck they want with it.
I can do the parts of LWP::Simple and parsing of the page into a hash just fine, I've done this countless times before.
My question is, since they are using my module "MetaParser.pm" , the module needs a way to GET the $url from the script. LWP::Simple does it like my $content = get("$url");
I want to do a similar function and maybe call it my $content = getm("$url");
Can anyone help me figure out how to setup getm(); to work?
Secondly, I am storing all the meta tag content in a hash (meta name => meta content). I need to know how I can export this hash into the script EASILY. I don't want to do main::MetaParser.. or whatever that is. There's got to be an easy way to get my hash into the script.
Thirdly, is there a way to instead of using my $content = getm("$url"); to use my %content = getm("$url"); and have the hash they just created actually be the hash that the script makes with the content? I think this would be a better bet, otherwise the scalar $content would be useless throughout the script. It would be nice if they could do it this way and have %content already set up.
This isn't much so far, but this is what I have:
Module:
Script:
I want to make it simple but something I'll likely use, so I decided on a meta tag parser. The module will use LWP::Simple and parse a given $url and strip ALL meta content into a hash then export the hash into the script so the admin/script user can do whatever the heck they want with it.
I can do the parts of LWP::Simple and parsing of the page into a hash just fine, I've done this countless times before.
My question is, since they are using my module "MetaParser.pm" , the module needs a way to GET the $url from the script. LWP::Simple does it like my $content = get("$url");
I want to do a similar function and maybe call it my $content = getm("$url");
Can anyone help me figure out how to setup getm(); to work?
Secondly, I am storing all the meta tag content in a hash (meta name => meta content). I need to know how I can export this hash into the script EASILY. I don't want to do main::MetaParser.. or whatever that is. There's got to be an easy way to get my hash into the script.
Thirdly, is there a way to instead of using my $content = getm("$url"); to use my %content = getm("$url"); and have the hash they just created actually be the hash that the script makes with the content? I think this would be a better bet, otherwise the scalar $content would be useless throughout the script. It would be nice if they could do it this way and have %content already set up.
This isn't much so far, but this is what I have:
Module:
Code:
package TestPrint;
use Exporter;
@ISA = 'Exporter';
@EXPORT_OK = qw(test_print);
use strict;
sub test_print
{
use LWP::Simple;
return;
}
1;
__END__
Script:
Code:
#!/usr/bin/perl
use warnings;
use strict;
use TestPrint qw(test_print);
&test_print;