in reply to Passing variables

How are you loading the .pl file, and what do you expect it to do? The usual thing would be something like this,

# in foo.cgi: my $password = 'thesecret'; require 'thefile.pl'; my $encoded = encrypto( $password );
The phrasing 'pass data to the file' sounds like you are trying some other usage. You should look at scoping, particularly file scope, to see what data is shared with a loaded file.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: Passing variables
by intranetman (Acolyte) on Sep 13, 2004 at 16:34 UTC
    You were dead on with your assumption. My setup is as follows:
    #in foo.cgi my $password = 'thesecret'; require 'thefile.pl'; my $encode = encrypto($password); #in thefile.pl sub encrypto($) { # encryption algorithm ... return $Finished; }
    I then get an error message that says  thefile.pl did not return a true value at foo.cgi line 10. Line 10 is the  require 'thefile.pl' line.

      That error message would have simplified the answer. From perldoc -f require,

      The file must return true as the last statement to indicate successful execution of any initialization code, so it's customary to end such a file with "1;" unless you're sure it'll return true otherwise. But it's better just to put the "1;", in case you add more statements.

      After Compline,
      Zaxo

        Thanks for the reply everything works well now. Interesting usages. Perldoc = Savior. Much appreciated.