in reply to Parsing cgi variable lists

Okay, I tried an above suggestion and this worked out:
my @lineitems = @{ $ARGS{ LineItem } }; foreach my $line (@lineitems) { print "line is $line"; my $first = $ARGS{"first-$line"}; my $second = $ARGS{"second-$line"}; my $third = $ARGS{"third-$line"}; print "first is $first"; print "second is $second"; print "third is $third"; }

This appears to be working now. Thanks for the help!


Michael Jensen

Replies are listed 'Best First'.
Re^2: Parsing cgi variable lists
by davidrw (Prior) on Jun 29, 2005 at 15:37 UTC
    In the future (and in general cases where data structure isn't known), a simple
    use Data::Dumper; warn Dumper \%ARGS; warn Dumper $ARGS{LineItem};
    would have show that it was an array ref, leading immediately to the @{$ARGS{LineItem}} solution.

    Also, in mason you can do this:
    <%args> $LineItem=>[] </%args> <%init> warn join ":", @$LineItem; ... </%init>
    That takes care of the case where just one LineItem form element exists. Using that syntax, you'll still get an array ref. Using the above $ARGS{LineItem} syntax you'll get a scalar, which will make the @{$ARGS{LineItem}} solution error out.