atento has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; use Data::Dumper; my $obj = MyTest->new(); #$obj->param('test', 555); #works fine #$obj->param('test2', 55522); #works fine $obj->param('test') = 555; $obj->param('test2') = 55522; my @params = $obj->param(); print Dumper(@params); package MyTest; sub new { bless { 'session' => {} }, shift; } sub param { my $self = shift; my $name = shift; my @val = @_; $self->{session}->{$name} = $val[0] if @_; unless(@val) { return keys %{$self->{session}} unless $name; return $self->{session}->{$name}; } } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to create multipurpose lvalue sub such as CGI::param ?
by kyle (Abbot) on Mar 22, 2008 at 13:02 UTC | |
|
Re: How to create multipurpose lvalue sub such as CGI::param ?
by dragonchild (Archbishop) on Mar 22, 2008 at 17:59 UTC | |
by chromatic (Archbishop) on Mar 22, 2008 at 18:07 UTC | |
by dragonchild (Archbishop) on Mar 22, 2008 at 18:46 UTC | |
by chromatic (Archbishop) on Mar 23, 2008 at 04:01 UTC | |
by dragonchild (Archbishop) on Mar 24, 2008 at 17:39 UTC | |
|
Re: How to create multipurpose lvalue sub such as CGI::param ?
by Anonymous Monk on Mar 22, 2008 at 16:36 UTC |