--- "Graeme St. Clair" <[EMAIL PROTECTED]> wrote:
> Now I have another Q arising out of this.  I have an irreducible pair
> of
> 'requires explicit package name' msgs that I can't see how to fix. 
> One
> example is:-
> 
> ...perl perl perl
> require 'bunch_of_constants.pl';
> ...perl perl perl
> $html .= <<EOF;
> ...html html html
> <form action="$one_constant" target="_blank" method="POST" name="Data
> Request" onSubmit="...">
> ...html html html
> EOF
> 
> $one_constant is defined in bunch_of_constants.pl, which is in the
> path all
> right, and which is not a package.  I've tried
> bunch_of_constants::$one_constant and main::$one_constant, but
> neither
> achieved anything.

What needs to change can depend upon what is in
"bunch_of_constants.pl".  If, in that script, you've declared your
variables with "my", then you will not be able to easily get at them. 
You can create a wrapper subroutine that returns them, however.

If they are truly package variables, though, then you determine the
package that they're in and you put the dollar sign at the front of the
variable name (assuming, in this case, that they're in the "main"
package):

  $main::one_constant

However, I would urge you to turn "bunch_of_constants.pl" into a proper
module and using Exporter.

References:

  perldoc -f my
  perldoc -f package
  perldoc perlmod
  perldoc Exporter

Cheers,
Ovid

=====
Silence is Evil            
http://users.easystreet.com/ovid/philosophy/decency.html
Ovid                       http://www.perlmonks.org/index.pl?node_id=17000
Web Programming with Perl  http://users.easystreet.com/ovid/cgi_course/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to