Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Perhaps

by pwhysall (Acolyte)
on Mar 01, 2001 at 21:19 UTC ( [id://61585]=note: print w/replies, xml ) Need Help??


in reply to Re: As usual
in thread Recursive directory scanning

This regex, I think, will match . or .. and nothing else:

/^\.{1,2}$/

Replies are listed 'Best First'.
Re: Perhaps
by merlyn (Sage) on Mar 01, 2001 at 21:49 UTC
    Good thing you're just "thinking". It also matches ".\n" and "..\n", thanks to $'s little-understood feature of matching before the optional newline at the end of the string.

    Perhaps you want

    /\A\.{1,2}\z/

    -- Randal L. Schwartz, Perl hacker

Re: Perhaps
by Tyke (Pilgrim) on Mar 02, 2001 at 13:38 UTC
    This is true, and that would break the script :(

    Remember that $item has been prefixed by the directory, so we want to filter out elements like foo/bar/. and fi/fo/fum/..

    Better would be to extract the file name and compare it to current/parent directory in a portable fashion. this will work on *nix or windows. I have no idea what it might do on a MAC or on VMS.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://61585]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-19 21:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found