I fixed all of the bugs save one. I can't access any of my subroutines without
explicitly using it with dates_emails::subroutine. I was under the impression
that if I was exporting them all from the module, the subroutine would be found
regardless.
package dates_emails;
require Exporter;
use strict;
our @ISA = qw(Exporter);
our @EXPORT = qw(startDate, endDate, searchStart, searchEnd);
our @EXPORT_OK = qw($emailTo, $emailFrom, $emailBcc);
our %EXPORT_TAGS = {
dates => [qw(startDate, endDate, searchStart, searchEnd)],
emails => [qw($emailTo, $emailFrom, $emailBcc)],
};
our $VERSION = '1';
It doesn't even work with 'use dates_emails("dates");'. I get an error that
dates is not an exported subroutine. I don't understand what I'm not doing
right as I've got the %EXPORT_TAGS hash set up, I've got the @EXPORTS array set
up. I've got this in my opening block:
use lib '/usr/local/bin/lib/';
use dates_emails;
Any thoughts?
Mathew
Keep up with me and what I'm up to: http://theillien.blogspot.com
Martin Barth wrote:
> Hi,
>
> try:
>
> use lib "/usr/local/bin/lib/";
> use dates_email;
>
> HTH Martin
>
> On Thu, 14 Jun 2007 01:50:57 -0400
> Mathew Snyder <[EMAIL PROTECTED]> wrote:
>
>> To take this further I've changed the code. It now looks like this:
>>
>> package dates_emails;
>> require Exporter;
>> use strict;
>>
>> our @ISA = qw(Exporter);
>> our @EXPORT = qw(startDate, endDate, searchStart, searchEnd);
>> our @EXPORT_OK = qw($emailTo, $emailFrom, $emailBcc);
>> our %EXPORT_TAGS = {
>> dates => [qw(startDate, endDate, searchStart, searchEnd)],
>> emails => [qw($emailTo, $emailFrom, $emailBcc)],
>> };
>> our $VERSION = '1';
>>
>> # Declare our global variables
>> my (@days, @months, @years, @searchDate);
>> my $time = time();
>>
>> our $emailTo = "[EMAIL PROTECTED]";
>> our $emailFrom = "RT";
>> our $emailBcc = "[EMAIL PROTECTED]";
>>
>> sub getDates {
>> for (1 .. 7) {
>> $time -= 24*60*60;
>> my @date = (localtime($time))[3 .. 5];
>> push @days, (sprintf '%02d', $date[0]);
>> push @months,(sprintf '%02d',$date[1] + 1);
>> push @years, $date[2] + 1900;
>> return;
>> }
>>
>> sub searchDate {
>> getDates();
>> push @searchDate, join "-", ($date[2] + 1900), (sprintf
>> '%02d',$date[1]
>> + 1),
>> (sprintf '%02d', $date[0]);
>> return [EMAIL PROTECTED];
>> }
>>
>> sub startDate {
>> getDates();
>> $startDate = join "-", $months[$#months], $days[$#days],
>> $years[$#years];
>> return $startDate;
>> }
>>
>> sub endDate {
>> getDates();
>> $endDate = join "-", $months[0], $days[0], $years[0];
>> return $endDate;
>> }
>>
>> sub searchStart {
>> getDates();
>> $searchStart = join "-", $years[$#years], $months[$#months],
>> $days[$#days];
>> return $searchStart;
>> }
>>
>> sub searchEnd {
>> getDates();
>> $searchEnd = join "-", $years[0], $months[0], $days[0];
>> return $searchEnd;
>> }
>>
>> return 1;
>>
>> I've placed it in its own directory /usr/local/bin/lib. I've tried using
>> use '/usr/local/bin/lib/dates_email';
>> use '/usr/local/bin/lib/dates_email.pm';
>> use '/usr/local/bin/lib/dates_email qw/startDate/;
>> use '/usr/local/bin/lib/dates_email.pm qw/startDate/';
>> use '/usr/local/bin/lib/dates_email qw/"startDate"/;
>> use '/usr/local/bin/lib/dates_email.pm qw/"startDate"/';
>> use '/usr/local/bin/lib';
>>
>> Each one gives me the error "Undefined subroutine &dates_emails::startDate
>> called at ./created_tickets.pl line 19.". Anyone know what I'm doing wrong?
>>
>> Mathew
>> Keep up with me and what I'm up to: http://theillien.blogspot.com
>>
>>
>
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/