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
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}; }
}
I used it like this to test it in one of my scripts.
require "vars.pm";
open(NEWFILEXQ,">>13x.txt") || die $!;
print NEWFILEXQ A->main_html_dir(),;
close(NEWFILEXQ);
It works, but I am wondering if this is a good way to avoid using
globals
Hi,
I have 3 cgi scripts that need to share some data
Lets say I created a PM file with a hash in it.
my $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',
};
How can I get the values from the hash in the PM file to the cgi script(s) as they require them
In reply to hash pm
by toniax
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.