http://www.perlmonks.org?node_id=305115


in reply to question regarding slices

I can't think of how to do this, since it is a list instead of an array... it might not be possible. With lists you can use -1 to get the last element, but 2 .. -1 doesn't seem to work.

What about using grep to avoid the check for . and .. within the foreach?

foreach (grep { !/^\.\.?$/ } readdir(PRINT)) { # stuff }

I know this isn't what you asked for, but it is another solution. Personally I prefer having the check within the foreach loop like this:

next if (/^\.\.?$/);

Hope that helps.
Brad