[thelist] Perl loop -1

Kevin webmaster at websitesupdate.com
Thu Feb 27 23: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.

foreach $field (@Field_Order) {
    next if ($field =~ m/submit/i);
    print "$field: $Form{$field}<br />\n";
}

There you are.

-K





More information about the thelist mailing list