--On Monday, September 29, 2003 19:04 -0700 "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:

test.pl
-------
use mystuff;

print mystuff::trim($username);

mystuff.pm
----------
# do i need any declaration line here
# is sub here or what?
# and where do i put this pm file?

sub trim
{ my $z = $_[0];
  $z =~ s/^\s+//;
  $z =~ s/\s+$//;
  return $z;
}

You're almost good. Add '1;' to the end of mystuff.pm, just to return a true value when it compiles, and 'package mystuff;' to the beginning of the same so Perl knows it is a package. Also 'use warnings' and 'use strict' would be good in both...


As for where you put it: wherever you want. Just make sure that it gets included in the @INC path. The easiest is in the same folder as test.pl (assuming you always run test.pl from there), since the current folder is in the path.

Daniel T. Staal

---------------------------------------------------------------
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to