Since you are using CGI you can do this and stick all your params in a single hash:
my %params = $cgi->Vars; # Now Kanji's code becomes foreach my $file ( qw (file1 file2 file3 ...) ) { push @tour_photos, $params{$file} if exists($params{$file}) && $params{$file} ne ''; }

Update: Took the incorrect commas out of the qw(), *sigh* posting on weekends again... and changed 'defined' to 'exists' since it is now in a hash.

Since it came up in chatterbox, I'd like to point out that CGI will take a multiple items with the same form 'name' and cram them into an array. Fastolfe demonstrated that in another post here. I should warn you that if the various "fileXX" files have specific purposes then that method may not be for you. Order from the client isn't guaranteed to be the same as the order in the HTML form. I can't recall a browser that fails to do so off the top of my head but that fact is out there, waiting to bite the overconfident. Like, for instance, me. =)

Up-Update Kanji kindly points out that the Vars method of CGI happens to act like cgi-lib.pl and it puts multiple items into a single string separated by friggin' nulls "\00" so while the above is correct in warning you about disordered items, it is miserably wrong about how Vars treats your lists. =) Now, I'm going to crawl under a rock, thank you and good night.

--
$you = new YOU;
honk() if $you->love(perl)


In reply to Re: Simplifying the following code by extremely
in thread Simplifying the following code by Stamp_Guy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.