Please bottom post....

J Adam Latham wrote:
Try removing "my" from all the variables in your module ... You're privatizing them to your module thereby excluding them from your external program ...

At least that's my guess! :^)


Hopefully you could at least suggest to 'our' them instead of 'my', so that 'strict' checking can remain in play, as it should remain in play....


perldoc -f our

In general this is where drieux would interject his ramblings about how you have reached a point where you probably want to brew your own module (check the list archives for such rantings which are usually very informative), which is simple enough to do.

I would suggest reading up on creating your own module,

perldoc perlmod
perldoc perlmodlib
perldoc -f package
perldoc -f use
perldoc Exporter

Essentially you create a separate file, a .pm, throw a package statement in there, make it an Exporter if you so desire, 'our' a few variables, then in your scripts you simply 'use' it. Back in business.... when you get stuck ask more questions.

http://danconia.org


HTH,
Adam

On Tuesday 04 May 2004 12:12 pm, Andrew Gaffney wrote:
: I'm working on a small Perl-based webapp. I want to create a small include
: file that all scripts will use. It looks like:
:
: <code>
: use CGI;
: use DBI();
:
: my $cgi = new CGI;
: my $dbh = DBI->connect("DBI:mysql:database=somedb;host=127.0.0.1", "user",
: "pass"); my $p = $cgi->Vars;
: my $uid = $cgi->cookie('uid');
: if($uid eq '') {
:    print $cgi->header;
:    print
: "<html><script>location.replace('/cgi-bin/login.pl');</script></html>"; }
:
: 1;
: </code>
:
: In my scripts, I do 'require "./common.pl";' but I get errors when I try to
: use the variable defined in common.pl. Am I doing something wrong? Am I
: going about this completely the wrong way?
:
: --
: Andrew Gaffney
: Network Administrator
: Skyline Aeronautics, LLC.
: 636-357-1548


-- 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