toniax has asked for the wisdom of the Perl Monks concerning the following question:
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);
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', };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash pm
by fullermd (Vicar) on Nov 30, 2010 at 03:04 UTC | |
by toniax (Scribe) on Nov 30, 2010 at 03:22 UTC | |
by fullermd (Vicar) on Nov 30, 2010 at 03:36 UTC | |
by toniax (Scribe) on Nov 30, 2010 at 15:48 UTC |