toniax has asked for the wisdom of the Perl Monks concerning the following question:
Hello again,
I figured out a solution . I found this snippet of code on here and
used part of it for my purpose. What I did is create a file called
vars.pm with this code in it
Hi,
I have 3 cgi scripts that need to share some data
Lets say I created a PM file with a hash in it.
I figured out a solution . I found this snippet of code on here and
used part of it for my purpose. What I did is create a file called
vars.pm with this code in it
I used it like this to test it in one of my scripts.package A; { my $vars = { main_html_dir => '/home/x/public_html/13X', script_url => 'http://www.13/cgi-bin/13X/NEW/13x.cgi', html_dir => 'http://www.13/13X', script_dir => '/home/x/public_html/cgi-bin/13X/', ext => 'html', }; sub main_html_dir { return $vars->{main_html_dir}; } sub script_url { return $vars->{script_url}; } sub html_dir { return $vars->{html_dir}; } sub script_dir { return $vars->{script_dir}; } sub ext { return $vars->{ext}; } }
It works, but I am wondering if this is a good way to avoid using globalsrequire "vars.pm"; open(NEWFILEXQ,">>13x.txt") || die $!; print NEWFILEXQ A->main_html_dir(),; close(NEWFILEXQ);
Hi,
I have 3 cgi scripts that need to share some data
Lets say I created a PM file with a hash in it.
How can I get the values from the hash in the PM file to the cgi script(s) as they require themmy $vars = { main_html_dir => '/home/x/public_html/13X', script_url => 'http://www.13/cgi-bin/13X/NEW/x.cgi', html_dir => 'http://www.13/13X', script_dir => '/home/x/public_html/cgi-bin/NEW', };
Back to
Seekers of Perl Wisdom