It goes through the values in @display_files, checking each of them in turn against the value of param('select') (which is almost certainly a CGI input parameter).

As the "grep" function is called in scalar context ("unless" evaluates its arguments in scalar context) then it returns the number of items in @display_files that matched param('select'). If that number is zero then the "unless" returns true.

Or more simply, it looks to see if the value of param('select') is found in @display_files and if it's not there, the code following the "unless" condition is executed.

And it does it all in a rather inefficient manner. A more efficient version might look something like this:

my $select = param('select'); my $found; foreach (@display_files) { if ($_ eq $select) { $found = 1; last; } } unless ($found) { # do something }

See perldoc -f grep for more explanation of "grep" and perldoc perlsyn for more explanation of "unless".


In reply to Re: Just 1 line explanation by davorg
in thread Just 1 line explanation by Nik

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.