--- Philip Peeters <[EMAIL PROTECTED]> wrote:
>       %newdata = ();
>       $newdata{$TAG} = $co->param('account');
>       $newdata{$TAG}[initsearch] = $co->param('initsearch');
>       $newdata{$TAG}[team] = $co->param('team');
>       $newdata{$TAG}[website] = $co->param('website');

There are a couple of problems here.  First:

    $newdata{$TAG} = $co->param('account');

You're assiging a scalar value to $newdata{$TAG}, but then:

    $newdata{$TAG}[initsearch] = $co->param('initsearch');

You want curly braces {} instead of the square braces [] (curly indicates a hash, the 
square
indicates an array).  However, even that doesn't solve the problem because now you're 
trying to
use $newdata{$TAG} as a ref to an anonymous hash when you've previously assigned a 
scalar to it. 
You'll wipe out the scalar value.  Here's my guess as to what you want:
    #!/usr/bin/perl -wT
    use strict;
    use CGI;
    use Data::Dumper;

    my $co = CGI->new;

    my %newdata;
    my $tag = 'test';

    my @form_elements = qw/ account initsearch team website /;
    my @temp_values;

    foreach my $element ( @form_elements ) {
        $newdata{ $tag }{ $element } = $co->param( $element );
    }
    print Dumper \%newdata;

When called from the command line with the following:

   ./test.pl account=test initsearch=first team=alpha website=perlmonks

It will print the following data structure:

    $VAR1 = {
              'test' => {
                          'initsearch' => 'first',
                          'account' => 'test',
                          'team' => 'alpha',
                          'website' => 'perlmonks'
                        }
            };

Then, to access the 'account' data for $tag, you use this:

    my $data = $newdata{$tag}{'account'};

Hope that helps!

Cheers,
Curtis Poe

=====
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Reply via email to