Perl Monk, Perl Meditation | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Is there an alternative to using the $self->param() function of CGI::Application to access an application-wide data structure, while still staying true to the CGI::Application paradigm?
In my homebrewn script before C::A, I used a global %hash. Back then I could access my %hash in print contexts or similar like this print "this funky var: $hash->{funky}"; Doing the same with the param() function does not work, as it is a subroutine reference and not a var: print "this funky var: $self->param('funky')"; Also declaring values with param is sometimes tedious: $self->param('key') = \%valuehash (which gives an lvalue error...) As I think, there are two ways of solving this: 1. declaring my %hash as our at the start of MyApp.pm -or- 2. pulling the $self->param() values into scope at the entry of each runmode subroutine
Both ways seem to be a deroute from the CGI::Application approach. Some feedback on best practice here is very welcome! (Would loosening my use strict; pragma make life easier?) BTW: sorry for this being not-exactly-perl-related.. In reply to CGI::Application - alternative to using $self->param? by isync
|
|