Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Syntactic Confectionery Delight
 
PerlMonks  

Re: question regarding slices

by duct_tape (Hermit)
on Nov 06, 2003 at 13:46 UTC ( [id://305115]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://305115]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.