in reply to Referents Anonymous.
Assuming you trust your ability to get reliable data from CGI::param() (and there's no reason not to), you should be safe.my $hashref = {}; my @params = qw( abc_1 abc_2 abc_3 cba cdr car ); foreach my $param (@params) { if ($param =~ /^abc_/) { $hashref->{$param} = [ 'column', 'text' ]; } } use Data::Dumper; print Dumper($hashref);
I can't see any reason why this wouldn't work right. However, I'd probably skip the if check and build a hash of allowed parameters and array references and do something like:
It depends on what you're doing with $hashref, I suppose.foreach my $param ($cgi->param()) { if (defined(my $arr_ref = $options{$param})) { $hashref->{$param} = $arr_ref; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: Referents Anonymous.
by PsychoSpunk (Hermit) on Sep 30, 2000 at 00:39 UTC |