Global Variables

[email protected] (Sean Carte) Fri, 13 Jul 2001 14:52:41 +0200
Newsgroups perl.macperl.webcgi
Message-ID <a05100304b7749a20233e@[192.168.1.6]>
How can I set and access global variables?

The following script prints 'tweetie sylvester' when run locally, but 
when run as a CGI script, it only prints: 'tweetie'.

#!/usr/bin/perl -w
use strict;

my $var = 'tweetie';

if ($var) {
     local $main::var = 'sylvester';
}

print "Content-type: text/html\n\n";
print $var, ' ', $main::var, "\n";
exit 1;

__END__
-- 
My brain hurts!
SeanC
                      Mediatek Training Institute
            26 Crart Ave., Berea, Durban, South Africa
    phone: +27 (0)31 202 1886              [email protected]
       fax: +27 (0)31 202 1767
                   <http://members.nbci.com/s_carte/>