[thelist] Perl loop -1

Chris Marsh chris at ecleanuk.com
Fri Feb 28 06:35:01 CST 2003


> Again my Perl skills (-x) are showing. What is the way to
> change the loop below to cycle through $field and print all
> of them *except* the last one?
>
> ################################
>   foreach $field (@Field_Order) {
>      print "$field: $Form{$field}<br />\n";
>   }
> ################################
>
> Obviously this is a loop to read a form page. I just
> don't want the final value which is the "Submit" button.

my $submit = pop @Field_Order;
foreach $field (@Field_Order) {
   print "$field: $Form{$field}<br />\n";
}

HTH

Regards

Chris Marsh




More information about the thelist mailing list