in reply to using perl variable in muliple modules

It sounds like you're asking how make functions from other namespaces catch input parameters, yes?

The answer is: same way you do it in a regular function. Perl passes all input parameters in the array @_, and automagically shuffles @_ from namespace to namespace when you call an object method. Your modules will probably end up looking something like this:

package NewTitle1; sub titler { my $input_value = shift; my $title = ## munge $input_value into a title return ($title); } package NewMeta; sub newDesc { my $input_value = shift; my $meta = ## munge $input_value into a meta tag return ($meta); } package MakeLink; sub exportLinks { my $input_string = shift; my @links = ## munge $input_value into a list of links return ($meta); }

Replies are listed 'Best First'.
Re: Re: using perl variable in muliple modules
by jeremy_goodrich (Initiate) on Dec 28, 2001 at 01:30 UTC
    thanks for the help :) okay, another related question:
    ($self, $keyword, $keyword2, $keyword3, $keyword4, $keyword5, $keyword +6, $domain) = (@_);
    That's how I'm getting a series of values into a module, which seems to be working...however, when I parse those with this:
    $sub1 = $keyword; $sub2 = $keyword2; $sub3 = $keyword3; $sub4 = $keyword4; $sub5 = $keyword5; $sub6 = $keyword6; $noun1 = &makeNlink($sub1, $domain); $noun2 = &makeNlink($sub2, $domain); $noun3 = &makeNlink($sub3, $domain); $noun4 = &makeNlink($sub4, $domain); $noun5 = &makeNlink($sub5, $domain); $noun6 = &makeNlink($sub6, $domain);
    and then this is the sub &makeNlink
    sub makeNlink { #($tobelink, $tobelinkurl) = @_; $tobelink = shift(@_); $tobelinkurl = shift(@_); $withspaces = $tobelink; $tobelink =~ s/\s/_/g; chomp($withspaces); chomp($tobelink); $totallyscrewed = "<a href \= \"http\:\/\/$domain\/$tobelink\" +>$withspaces<\/a>"; return $totallyscrewed; }
    The values are used over and over, the same series each time, when in the main script they are totally different. How do I make sure the current value of each variable is imported into this module? Thanks very, very much for the help! This place rocks.
      I suspect from your question that you are having problems with overwriting the value of your variables. If so then what you need to do is stop using so many global variables. I strongly recommend reading Coping With Scoping to understand how to avoid having variables trample all over each other, and then strict.pm to find out how to let Perl give you feedback to avoid mistakes.