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. in the path where perl.exe
> looks for modules and libraries. @INC includes current working directory
> (NOT the directory in which your tst.pl resides, but the one where you
> call tst.pl from), plus /path/to/perl/lib and /path/to/perl/site/lib.
> Well, usually.
> If you want to know for sure what does your @INC include:
>         prompt> perl -e "print qq(@INC)"
>
> 2. You should specify full path to your library:
> require "/path/to/mycommon.pl"

Way too much trouble.  All he has to do is drop the extension.  Perl does
funky things with it.  Or he could put the filename in single quotes.  Both
approaches worked for me.  I must admit to being a bit rusty on functional
modules.  What I am finding is that minimal is best.

Having a package statement and using Exporter in a functional module screwed
things up.
Having filename extensions without single quotes screwed me up--the error
inidcate that the dot was taken as a dot operator rather than part of the
single string, so it was looking for MyCommonpm, rather than MyCommon.pm.

Here is what worked:

MyCommon.pm:
sub do_wrap {
    my $retval;

    if(length($_[0]) == 0) { $retval = "null"; }
    else { $retval = "'" . $_[0] . "'"; }
}

1;
_END_

test_my_common.pl:
#perl -w

require (MyCommon);

print do_wrap("hello");

Greetings! E:\d_drive\perlStuff>test_my_common.pl
'hello'
Greetings! E:\d_drive\perlStuff>

HTH,

Joseph


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

Reply via email to