Not the way you are thinking, but yeah, it can be done... # Untested! my %data; foreach my $name ( param() ) { # match the format, grab the data, and skip # irrelevant form fields $name =~ /^(\w+)_(\s+)$/; my $type = $1; my $num = $2; next unless ( $type );
$data{$num}->{$type} = param($name); } foreach my $num ( sort {$a <=> $b} (keys %data) ) { my %fields = %{$data{$num}}; print "These are for entry number $num<br>"; print "The ID is $fields{ID}<br>"; print "The phone is $fields{phone}<br>";} #...etc. } The first part reads in all the data and seperates it by number and type. The second part iterates over each number. So the first pass of the second loop returns the data for _1, the second pass returns the data for _2, etc. I didn't test it, so it might have some syntax errors. Rob -----Original Message----- From: Imtiaz ahmad [mailto:[EMAIL PROTECTED]] Sent: Monday, January 21, 2002 4:22 PM To: Hanson, Robert; '[EMAIL PROTECTED]' Subject: RE: Question - Is it possible to read them without IF ELSE by somehow reading all variable together in each LOOP? for example, ID_1, USER_1, NAME_1 in first LOOP and then ID_2, USER_2, NAME_2 in second LOOP with the current set up we will be reading one variable with each LOOP and if we have two set of variables as in the above example it will take 6 LOOPs but I want to be able to read the whole in each LOOP. thanks. -----Original Message----- From: Hanson, Robert [mailto:[EMAIL PROTECTED]] Sent: Monday, January 21, 2002 12:28 PM To: 'Imtiaz ahmad'; '[EMAIL PROTECTED]' Subject: RE: Question - I think this is what you wanted... use CGI qw/:standard/; # Loop over each field name in the form foreach my $name ( param() ) { # If the name starts with "ID_" ending with a number if ( $name =~ /^ID_\d+$/ ) { print "It's an ID! The value = " . param($name) . "<br>"; } # If the name starts with "user_" ending with a number elsif ( $name =~ /^user_\d+$/ ) { print "It's a user! The value = " . param($name) . "<br>"; } # etc, etc, etc... } Rob -----Original Message----- From: Imtiaz ahmad [mailto:[EMAIL PROTECTED]] Sent: Monday, January 21, 2002 12:13 PM To: Hanson, Robert; '[EMAIL PROTECTED]' Subject: RE: Question - Can we read multiple variable like that? For example, if we have ID_1, ID_2, ID_3 ...ID_n and user_1, user_2, user_3 ...user_n name_1, name_2, name_3 ...name_n and phone_1, phone_2, phone_3 ...phone_n thanks. -----Original Message----- From: Imtiaz ahmad [mailto:[EMAIL PROTECTED]] Sent: Monday, January 21, 2002 11:58 AM To: Hanson, Robert Subject: RE: Question - thanks again --- it works perfectly. -----Original Message----- From: Hanson, Robert [mailto:[EMAIL PROTECTED]] Sent: Monday, January 21, 2002 11:57 AM To: 'Imtiaz ahmad'; Subject: RE: Question - You could use CGI.pm. use CGI qw/:standard/; foreach my $name ( param ) { # Skip everything except ID_# vars next unless ( $name =~ /^ID_\d+$/ ); # Handle variable here print "$name = ".param($name); } Is that what you were asking or did you want to pass the vars between pages? If you need to pass them you can either drop them into hidden for fields, or use some sort of session mgmt (like Apache::Session). Rob -----Original Message----- From: Imtiaz ahmad [mailto:[EMAIL PROTECTED]] Sent: Monday, January 21, 2002 10:48 AM To: [EMAIL PROTECTED] Subject: Question - Can someone please help me with the following: I need to have variable names like ID_1, ID_2, ID_3 ...ID_n. How can I read them on the next page after submitting through a FORM using POST method? thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]