Re: how to reuse sub

2003-10-08 Thread R. Joseph Newton
[EMAIL PROTECTED] wrote: > I guess, you're the man! > > Your code works. I did not know of the Exporter. > > What happens if there are several package with the same name and exported? > > thanks, > rkl Then you have to prepend the name. For some reason the term is slipping my mind, but a sub dec

Re: how to reuse sub

2003-10-08 Thread perl
I guess, you're the man! Your code works. I did not know of the Exporter. What happens if there are several package with the same name and exported? thanks, rkl > [EMAIL PROTECTED] wrote: > >> > my $return = do_wrap('hello'); >> >> Doesn't this have to be MyCommon::do_wrap('hello'); ? > > No.

Re: how to reuse sub

2003-10-07 Thread R. Joseph Newton
[EMAIL PROTECTED] wrote: > > my $return = do_wrap('hello'); > > Doesn't this have to be MyCommon::do_wrap('hello'); ? No. You do not have to prepend the package name when Exporter is properly invoked. That proper invocation can be a bit tricky, though. That is why it sat for a few days, while

Re: how to reuse sub

2003-10-07 Thread perl
> my $return = do_wrap('hello'); Doesn't this have to be MyCommon::do_wrap('hello'); ? When running it, the error: Undefined subroutine &main::do_wrap thanks, -rkl > [EMAIL PROTECTED] wrote: > >> How can I reuse a subroutine? >> >> My environment is redhat 9, apache2, perl-5.8.0-88, mod_perl-1.

Re: how to reuse sub

2003-10-01 Thread R. Joseph Newton
[EMAIL PROTECTED] wrote: > How can I reuse a subroutine? > > My environment is redhat 9, apache2, perl-5.8.0-88, mod_perl-1.99_07-5. > I've tried to put the sub in a separate file and call it from another as > below. Please modify the snipet below to make it work. > > mycommon.pl > --- > #

Re: how to reuse sub

2003-09-27 Thread R. Joseph Newton
Zanardi2k3 wrote: > [EMAIL PROTECTED] wrote: > > > OK, I added the return line to sub. But I'm getting an error on the > > line require "mycommon.pl" of the tst.pl file. It say something about > > @INC cannot find mycommon.pl > > You have two choices: > > 1. Your required file must be in @INC, i.e

Re: how to reuse sub

2003-09-27 Thread Zanardi2k3
[EMAIL PROTECTED] wrote: > OK, I added the return line to sub. But I'm getting an error on the > line require "mycommon.pl" of the tst.pl file. It say something about > @INC cannot find mycommon.pl You have two choices: 1. Your required file must be in @INC, i.e. in the path where perl.exe look

Re: how to reuse sub

2003-09-27 Thread perl
OK, I added the return line to sub. But I'm getting an error on the line require "mycommon.pl" of the tst.pl file. It say something about @INC cannot find mycommon.pl any help here? How can I reuse a subroutine? My environment is redhat 9, apache2, perl-5.8.0-88, mod_perl-1.99_07-5. I've tried t

Re: how to reuse sub

2003-09-27 Thread Jeff 'japhy' Pinyan
On Sep 26, [EMAIL PROTECTED] said: >#!/usr/bin/perl >#return a value wrapped by single quotes >#should this be declare package something? >sub doWrap >{ my $retval; > > if(length($_[0]) == 0) { $retval = "null"; } > else { $retval = "'" . $_[0] . "'"; } >} You need to RETURN $retval. It's alwa