Re: using a homemade perl module
Mumia W. wrote: On 06/28/2007 10:22 PM, Mathew Snyder wrote: I'm getting a strange bit of behaviour. I have everything set up right and my dates are getting made up properly however, one sub which creates the searchDate array isn't being called. I have to enter the full module path (Reports::Dates::searchDate) for it to work while all of the other dates are called without problem using just the sub name. Any thoughts on why this might be? It works for me. People can only guess at the problem you're having because you didn't show the program that is failing. Also, the functions in Reports/Dates.pm are undocumented. Problem was I didn't have it listed in @EXPORTS The functions, with the exception of getDates() are fairly self-explanatory. 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/
Re: using a homemade perl module
On 06/28/2007 10:22 PM, Mathew Snyder wrote: I'm getting a strange bit of behaviour. I have everything set up right and my dates are getting made up properly however, one sub which creates the searchDate array isn't being called. I have to enter the full module path (Reports::Dates::searchDate) for it to work while all of the other dates are called without problem using just the sub name. Any thoughts on why this might be? It works for me. People can only guess at the problem you're having because you didn't show the program that is failing. Also, the functions in Reports/Dates.pm are undocumented. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: using a homemade perl module
Brad Baxter wrote: On Jun 14, 10:22 pm, [EMAIL PROTECTED] (Mathew Snyder) wrote: 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; use strict; add: use warnings; ... Possible attempt to separate words with commas at dates_emails.pm line 6. Possible attempt to separate words with commas at dates_emails.pm line 7. Possible attempt to separate words with commas at dates_emails.pm line 9. Possible attempt to separate words with commas at dates_emails.pm line 10. Reference found where even-sized list expected at dates_emails.pm line 8. That may not be your whole problem, but it might get you a little farther. -- Brad I need to revisit this. I've broken things down a bit and separated the email addresses from the date subs and now have two files under /usr/local/bin/lib/Reports: Dates.pm and Emails.pm. *Dates.pm:* package Dates; require Exporter; use strict; use warnings; our @ISA = qw(Exporter); our @EXPORT = qw(startDate endDate searchStart searchEnd); our $VERSION = '1'; # Declare our global variables my (@date, @days, @months, @years, @searchDate); my $time = time(); our (@searchDate, $startDate, $endDate, $searchStart, $searchEnd); sub getDates { for (1 .. 7) { $time -= 24*60*60; @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; The simple thing I'm trying to do to test all of this is: #!/usr/bin/perl ### # Title:module_test.pl # Author: Mathew Snyder # Reliease: 0.1 # Date: June 13, 2007 ### use warnings; use strict; use lib /usr/local/bin/lib; use Reports::Dates; my $today = startDate(); print $today . \n; Doing things this way gives me an error telling me that main::startDate isn't defined. However, if I use 'my $today = Dates::startDate;' it works. I'm confused since I told it to 'use Reports::Dates;'. Anyone have any insight on why this isn't working the way I've been told it should? Thanks, Mathew -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: using a homemade perl module
On 06/28/2007 03:00 AM, Mathew Snyder wrote: our @ISA = qw(Exporter); our @EXPORT = qw(startDate endDate searchStart searchEnd); our $VERSION = '1'; Those lines need to be within a BEGIN block. See perlmod: http://perldoc.perl.org/perlmod.html -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: using a homemade perl module
On Thu, Jun 28, 2007 at 06:58:36AM -0500, Mumia W. wrote: On 06/28/2007 03:00 AM, Mathew Snyder wrote: our @ISA = qw(Exporter); our @EXPORT = qw(startDate endDate searchStart searchEnd); our $VERSION = '1'; Those lines need to be within a BEGIN block. See perlmod: Are you sure? The package name should be Reports::Dates, not just Dates. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: using a homemade perl module
On 06/28/2007 07:46 AM, Paul Johnson wrote: On Thu, Jun 28, 2007 at 06:58:36AM -0500, Mumia W. wrote: On 06/28/2007 03:00 AM, Mathew Snyder wrote: our @ISA = qw(Exporter); our @EXPORT = qw(startDate endDate searchStart searchEnd); our $VERSION = '1'; Those lines need to be within a BEGIN block. See perlmod: Are you sure? The package name should be Reports::Dates, not just Dates. Ah, yes you're right. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: using a homemade perl module
Paul Johnson wrote: On Thu, Jun 28, 2007 at 06:58:36AM -0500, Mumia W. wrote: On 06/28/2007 03:00 AM, Mathew Snyder wrote: our @ISA = qw(Exporter); our @EXPORT = qw(startDate endDate searchStart searchEnd); our $VERSION = '1'; Those lines need to be within a BEGIN block. See perlmod: Are you sure? The package name should be Reports::Dates, not just Dates. Sweet! That was the problem. Thanks mucho 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/
Re: using a homemade perl module
Paul Johnson wrote: On Thu, Jun 28, 2007 at 06:58:36AM -0500, Mumia W. wrote: On 06/28/2007 03:00 AM, Mathew Snyder wrote: our @ISA = qw(Exporter); our @EXPORT = qw(startDate endDate searchStart searchEnd); our $VERSION = '1'; Those lines need to be within a BEGIN block. See perlmod: Are you sure? The package name should be Reports::Dates, not just Dates. I'm getting a strange bit of behaviour. I have everything set up right and my dates are getting made up properly however, one sub which creates the searchDate array isn't being called. I have to enter the full module path (Reports::Dates::searchDate) for it to work while all of the other dates are called without problem using just the sub name. Any thoughts on why this might be? 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/
Re: using a homemade perl module
Well the code looks ok. I just wrote some simple test code to do the same thing like you, but it worked as exepcted. Are there some differeces between that example and your code? HTH % ls Module.pm test.pl % cat Module.pm #!/usr/bin/perl -w use strict; require Exporter; our @ISA = qw/Exporter/; our @EXPORT = qw/do_sth/; sub do_sth { print done\n; } 1; % cat test.pl #!/usr/bin/perl -w use strict; use Module; do_sth(); % perl test.pl done % On Thu, 14 Jun 2007 22:22:06 -0400 Mathew Snyder [EMAIL PROTECTED] wrote: 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/
Re: using a homemade perl module
Martin Barth 写道: Well the code looks ok. I just wrote some simple test code to do the same thing like you, but it worked as exepcted. Are there some differeces between that example and your code? HTH % ls Module.pm test.pl % cat Module.pm #!/usr/bin/perl -w use strict; require Exporter; our @ISA = qw/Exporter/; our @EXPORT = qw/do_sth/; sub do_sth { print done\n; } 1; Here don't forget to add the package declare at the begin line: package Module; # notice this line use strict; require Exporter; ... Otherwise your module doesn't have its own namespace at all. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: using a homemade perl module
oh! you're right! i'm sorry. On Fri, 15 Jun 2007 16:51:48 +0800 Jeff Pang [EMAIL PROTECTED] wrote: Martin Barth 写道: Well the code looks ok. I just wrote some simple test code to do the same thing like you, but it worked as exepcted. Are there some differeces between that example and your code? HTH % ls Module.pm test.pl % cat Module.pm #!/usr/bin/perl -w use strict; require Exporter; our @ISA = qw/Exporter/; our @EXPORT = qw/do_sth/; sub do_sth { print done\n; } 1; Here don't forget to add the package declare at the begin line: package Module; # notice this line use strict; require Exporter; ... Otherwise your module doesn't have its own namespace at all. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: using a homemade perl module
On Jun 14, 10:22 pm, [EMAIL PROTECTED] (Mathew Snyder) wrote: 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; use strict; add: use warnings; ... Possible attempt to separate words with commas at dates_emails.pm line 6. Possible attempt to separate words with commas at dates_emails.pm line 7. Possible attempt to separate words with commas at dates_emails.pm line 9. Possible attempt to separate words with commas at dates_emails.pm line 10. Reference found where even-sized list expected at dates_emails.pm line 8. That may not be your whole problem, but it might get you a little farther. -- Brad -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: using a homemade perl module
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/
Re: using a homemade perl module
That worked. Thanks. Now I just need to figure out all of the undeclared variables ;) 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/
Re: using a homemade perl module
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/
Re: using a homemade perl module
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/