in reply to Referents Anonymous.

Looks like it should work to me. You could test it with something like the following:
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);
Assuming you trust your ability to get reliable data from CGI::param() (and there's no reason not to), you should be safe.

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:

foreach my $param ($cgi->param()) { if (defined(my $arr_ref = $options{$param})) { $hashref->{$param} = $arr_ref; } }
It depends on what you're doing with $hashref, I suppose.

Replies are listed 'Best First'.
RE: Re: Referents Anonymous.
by PsychoSpunk (Hermit) on Sep 30, 2000 at 00:39 UTC
    Thanks chromatic, I just needed a sanity check. It's been one of those days. Plus, this has been one of the first times that I've had a specific piece of code that I felt would be of use to others, and would also give me a chance to see MTOWTDI. I'm not tied to the current act of building the hashref, but the hashref is now in place so that I can't make significant changes to the end result. But in my case, the parameters that I put in at runtime do have known values in the anonymous array. It happens that I just don't know the keys.

    ALL HAIL BRAK!!!