Greetings! Thanks to all of you for your thoughts. I like Rob's idea of ORing $_[0] with 'The Little Engine That Could'. I'll try that. I'm pretty darn sure that Train.pm has a line that says "package Train;", but I'll double-check.
A bit of background: This program will eventually be used to manage the process of volunteers signing up over the Internet to work on trains run by the Cuyahoga Valley Scenic Railroad. I have a Schedule class to manage the overall process, a ScheduleDay class (whose file name is "ScheduleDay.pm" to manage the group of trains that will run on a particular day, and a Train class to manage an individual train. I am using the Apache server on my local machine, and running my test program through Internet Exporer, as in http://localhost/crew/traintest.cgi . Thanks again! RobR --- Bob Showalter <[EMAIL PROTECTED]> wrote: > Rob Richardson wrote: > > Greetings! > > > > I have the following class in a .pm file: > > > > use warnings; > > use strict; > > package ScheduleDay; > > > > use Train; > > > > sub new > > { > > my $self = {}; # $self is a reference to an anonymous, empty (for > > now) hash > > bless $self; > > return $self; > > } > > n.b. this constructor is not inheritable if you ever derive a > subclass from > ScheduleDay. You might want to consider using: > > sub new { > my $class = shift; > $class = ref $class || $class; > bless {}, $class; > } > > > > > sub AddTrain > > { > > my $self = shift; > > my $trainName = $_[0]; > > # $self->{$trainName} = new Train; > > # $self->{$trainName}->Load(@_); > > print " Added train named ", $trainName, "<br>"; } > > > > "Where no one has gone before!"; > > > > > > When I run perl -c on this, I get the following messages: > > Subroutine new redefined at Train.pm line 106. > > This is likely a problem in Train.pm, which you didn't share with us. > Do you > get the same message from perl -c Train.pm? > > > Useless use of a constant in void context at scheduleday.pm line > 24. > > A warning for the phrase. If you don't like the warning, replace the > phrase > with the more idiomatic literal 1; > > > scheduleday.pm syntax OK > > So scheduleday.pm compiles OK. But it should be named ScheduleDay.pm. > > > > > What is going on here? Why can't I have a class that uses another > > class and have both classes have a "new" method? What do I have to > > do to get this scoped correctly? > > You can have this. Your problems lie elsewhere. > > > > > Also, I am getting strange behavior when running this through > Internet > > Explorer. > > Running what through Internet Explorer? Assuming code not in evidence > :~) > > > If the print statement in AddTrain() is modified to avoid > > the use of $trainName, the program runs as expected and IE displays > a > > page with one line of print for every train I try to add. However, > if > > I try to print the name of the train as contained in $printName > (and > > as shown above), the result age is never displayed and IE just > waits > > and waits and waits for something that never happens. > > ??? > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > __________________________________________________ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
