john wrote:
: It seems like using 'require' is the way to go (since I don't have the time or
: experience to do modules at the moment).
: 
: I can get the required scripts and subroutines to call OK when there is only one
: sub per required file and I don't have to pass arguments.
: 
: When I try to pass args they don't seem to get picked up by the called script.
: Is this possible?

How are you writing the require files? It sounds like you're trying to
run the subroutine code by requiring the files.

The way to write them is to put the subroutines definitions into the
file, require the file *just once*, and call the subroutines by name.
Something like this:

===> mySubs.pl <===

sub f2c {
        return ($_[0] - 32) * 5 / 9;
}

sub c2f {
        return $_[0] * 9 / 5 + 32;
}

===> myScript <===
require 'mySubs.pl';

my $celsius = f2c(73);
my $fahrenheit = c2f(30);
# etc...

My apologies if I'm misunderstanding you.

-- tdk

Reply via email to