hey,
I am a novice in perl and trying to write a little login package
which i want to integrate into some scripts.
Is it stylistic okay / dangerous to open the session inside the package
for use with the in-package functions, and simultaneously
pass them to the script which uses the package? Or is there a better way
to do this?
Example:
use CGI::Session;
my $s;
sub new_session {
$s = CGI::Session->new() or croak CGI::Session->errstr();
}
sub check_perm {
my $req_perm = shift;
if ($s->param('_perm') < $req_perm) {
print $s->header(), 'sorry, no permussion';
exit();
}
}
-- some_script.pl --
use login;
my $s = new_session();
check_perm(1);
$s->param( _some_param => 'some_value');
my $value = $s->param('_some_param');
Please exuse my poor english,
regards
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.