Hi Joseph. R. Joseph Newton wrote: > Rob Richardson wrote: > > > Greetings! > > > > I have the following class in a .pm file: > > > > use warnings; > > use strict; > > package ScheduleDay; > > > > use Train; > > [snip] 'new' method > > > > sub AddTrain > > { > > my $self = shift; > > my $trainName = $_[0]; > > How are you calling this function. the formulation above looks like > the call should be: > AddTrain($schedule_day_object, $train_name);
Yes, but it's $schedule_day_object->AddTrain($train_name); which does that for you. > If that is the case, then your parameter catch would be neater and > more understandable as: > my ($self, $trainName) = @_; > > or: > my $self = shift; > my $trainName = shift; It's a tradition that methods start with: my $self = shift; my ( $trainName, $p1, $p2, $p3, @prest ) = @_; to separate the implicit parameter from the explcit one. But what Rob R wrote will do just as well. > > # $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. > > Useless use of a constant in void context at scheduleday.pm line 24. > > scheduleday.pm syntax OK > > Check the package statement in Train.pm, and try compiling it > separately before using it in this file. > > > 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. > > $trainName ain't there. You've already commented out to lines > dependent on this variable. Presumably this was because they raised > errors. Check how you are getting a value into $trainName. It looks good to me, but I'm still waiting on the code for Train.pm where all the bugs really are :) Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]