[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] confused about use/require and package declarations



William Neuhauser <willn@quando.com> writes:
}Before MacPerl 5.14r4, this worked:
}<main file>
}  require 'ctime.pl';
}  require 'DateUtil.pl'
}<DateUtil.pl>
}  require 'ctime.pl';
}  package DateUtil;
}  sub getDate {
}	my ($wkday, $mon, $date, $t, $yr) = split(' ', &ctime::ctime($_[0]));
}	return "$MoY_map{$mon}/$date/$yr";
}  }
}
}Now, perl complains:
}# Undefined subroutine &ctime::ctime called.
}File 'BotDates.pl'; Line 4
}
}It seens that no matter where I put the require (before or after the package
}declaration) and whether I refer to &ctime::ctime() or just &ctime(), I get
}some error message or another such as:
}# Undefined subroutine &ctime::ctime called.
}# Undefined subroutine &DateUtil::ctime called.
}
}How is one supposed to declare requires across multiple files so that
}they are understood in all files?  I feel like I've had to move these
}around from perl4 to perl5 now from an earlier perl5 to the current
}perl5.  I don't get it.

Use the source, Luke.  Look at the file :MacPerl Ä:lib:ctime.pl.  In it
you'll see that the author went to deliberate lengths to keep sub ctime out
of the package ctime namespace.  In other words, you address sub ctime as
"main::ctime()".  For some bizzare reason.  But if you put main::ctime (or
maybe in your case DateUtil::ctime; experiment) in place of ctime::ctime,
out pops an answer.

Even better is to stop using any library file that ends with .pl, since
they're unlikely to be supported or updated as time goes on.  POSIX::ctime
(the Camel is your friend) is supposed to emulate ctime(3), just as
ctime.pl is.  And sure enough

use POSIX "ctime";

print ctime(time)."\n";

gives

Fri Nov  7 18:11:17 1997

(Gee, I'd better go.)


}
}
}
}_______
}Will Neuhauser              willn@quando.com
}Chief Technical Officer, VP Development
}Quando, Inc.                Tel: 1 (503) 225-1988
}520 NW Davis Street         Fax: 1 (503) 225-1987
}Portland, OR  97209 USA
}
}
}
}***** Want to unsubscribe from this list?
}***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch


---
Paul J. Schinder
NASA Goddard Space Flight Center
Code 693, Greenbelt, MD 20771
schinder@pjstoaster.pg.md.us



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch