Hamish Whittal wrote: > Hello you very able, helpful people.... > > I have a Common.pm module used throughout all my other modules. > > I have the following: > > our @EXPORT = qw/$ERRORSTRING $DAY $MONTH $YEAR/; > > ($DAY, $MONTH, $YEAR) = (localtime)[3,4,5]; > $YEAR+=1900; > $MONTH+=1; > $ERRORSTRING = q($DAY/$MONTH/$YEAR ERROR [$this] : $error\n); > > Now I want to try to use this in my code, replacing $this by the > Package::subroutine name, and $error in every package, by the > appropriate error I have detected. > > But, alas it does not work. Complains about the fact the $this and > $error have not been defined in the Common.pm. > > What is a pretty standard way (if such a thing exists) of doing this > type of thing. I want to make all my errors look similar....varying only > the $this part and the actual error.
I'm not clear where $this and $error come from, but the module below can be used like this. use strict; use Common; print ERRORSTRING('a', 'b'); OUTPUT 13/6/2003 ERROR [a] : b HTH, Rob use strict; package Common; require Exporter; our @ISA = 'Exporter'; our ($DAY, $MONTH, $YEAR); sub ERRORSTRING { my ($this, $error) = @_; ($DAY, $MONTH, $YEAR) = (localtime)[3,4,5]; $YEAR += 1900; $MONTH += 1; qq($DAY/$MONTH/$YEAR ERROR [$this] : $error\n); } our @EXPORT = qw/&ERRORSTRING $DAY $MONTH $YEAR/; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]