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".
"The first rule of Perl club is you do not talk about Perl club." -- Chip Salzenberg
In reply to Re: Just 1 line explanation
by davorg
in thread Just 1 line explanation
by Nik
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |