Wiggins d'Anconia <[EMAIL PROTECTED]> writes:
[...]
> 'use' can be as simple or complex as you wish really. The only thing
> slightly more complicated is if @INC doesn't contain where your *.pm
> lives. But that would be a simple case of doing
>
> use lib ('/path/to/libs/');
>
> before your other use MyModule call. Of course you could be after the
> 'about as simple as it gets' 'require', so:
Bob Showalter <[EMAIL PROTECTED]> writes:
> There are several functions:
>
> perldoc -f do
> perldoc -f require
> perldoc -f use
Ahh I see how to do something sort of like slurping functinos ala shell
technique here with `use' and `require'. But different.
The `do' function seems to be the closest thing to the shell dot (.)
operator. Thanks.
Going a bit further here... It seems `use' and `require' have to have
more to work.
For example:
With these files in /usr/lib/perl5/site_perl/
(both files have the same content)
5.8.0/ pfnc pfnc.pm
cat use.pl
#!/usr/local/bin/perl -w
use pfnc;
print "trying function\n"
&lctime_ar;
cat require.pl
#!/usr/local/bin/perl -w
require "pfnc";
print "trying function\n";
&lctime_ar;
cat pfnc:
sub lctime_ar{
@ar = localtime;
$cnt = 0;
for(@ar){
print "Ele [$cnt] = $_\n";
$cnt++;
}
}
(ditto for pfnc.pm)
Results:
./use.pl
pfnc.pm did not return a true value at ./use.pl line 2.
BEGIN failed--compilation aborted at ./use.pl line 2.
./require.pl
pfnc did not return a true value at ./require.pl line 2.
But if I put a call to the function in the pfnc source file. It
works. But doesn't remember the function. and gives some warnings.
cat pfnc.pm
&lctime_ar;
sub lctime_ar{
@ar = localtime;
$cnt = 0;
for(@ar){
print "Ele [$cnt] = $_\n";
$cnt++;
}
}
Results:
use.pl
Ele [0] = 31
Ele [1] = 19
Ele [2] = 16
Ele [3] = 20
Ele [4] = 0
Ele [5] = 103
Ele [6] = 1
Ele [7] = 19
Ele [8] = 0
pfnc.pm did not return a true value at ./use.pl line 2.
BEGIN failed--compilation aborted at ./use.pl line 2.
./require.pl
Ele [0] = 31
Ele [1] = 26
Ele [2] = 16
Ele [3] = 20
Ele [4] = 0
Ele [5] = 103
Ele [6] = 1
Ele [7] = 19
Ele [8] = 0
pfnc did not return a true value at ./require.pl line 2.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]