Greetings!
I wrote the following trivial module:
package Trace;
sub trace
{
my $message = shift;
open (TRACE, ">>c:\\indigoperl\\htdocs\\data\\trace.log") or die
"Could not open trace file: $!\n";
print TRACE $message;
close TRACE;
}
my $motto = "Who invented this furshlugginer language anyway?";
I used it in the following even more trivial script:
#!/usr/bin/perl
use warnings;
use strict;
use Trace qw(trace);
trace ("This is from the tracetest program.\n");
As you are no doubt aware, this didn't work. Perl complained that it
didn't know about &main::trace(). I modifed the module by adding the
following lines after "package Trace":
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(trace);
Once I had those lines in, the script worked.
In the train schedule script that you are no doubt sick of hearing
about by now, my main program has the following lines:
use Schedule;
my $theSchedule = new Schedule;
$theSchedule->Load("somefile.csv");
The file schedule.pm has a line that says, "package Schedule;", but no
use of the Exporter module. The other modules I am using to represent
other objects in the system don't use Exporter either. Yet I can use
the objects and their methods without prefacing them with a symbol
name. Why don't I need a package name with them? Is it because I am
using them in an object-oriented way?
Thanks!
RobR
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]