Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: How to implement something similar to Unix's find syntax?

by sanPerl (Friar)
on May 25, 2007 at 12:29 UTC ( #617478=note: print w/replies, xml ) Need Help??

in reply to How to implement something similar to Unix's find syntax?

I am just trying to create a funny code. It accepts two arguments directory to search and filename
It will work on Unix. you can make it work on Windows by reversing the slash.
Just try perl <script name> <dir name> <file name>
my ($mydir, $word) = (@ARGV); opendir(DIR, "$mydir") || warn "can't opendir : $!"; @dots = grep { /\w/ } readdir(DIR); closedir DIR; foreach $dir_tree(@dots) { #print "$dir_tree\n"; opendir(DIR, "$dir_tree"); @dots1 = grep { /\w/ } readdir(DIR); foreach $dir_tree1(@dots1) { push @dots, "$dir_tree/$dir_tree1"; my $name = "$dir_tree/$dir_tree1"; print "$dir_tree/$dir_tree1\n" if ($name =~ m/\Q$word\ +E/is); } closedir DIR; }

Replies are listed 'Best First'.
Re^2: How to implement something similar to Unix's find syntax?
by moritz (Cardinal) on May 25, 2007 at 12:59 UTC
    I think the original intention was to implement a parser for options similar to find.

    If I understand the original posting correctly, it has nothing to do with actually finding files, but to apply that logic to a completely different problem.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://617478]
[Corion]: Discipulus: Yeah, a short vacation on the Canary islands (Lanzarote). Always great to be in the warmth and sun, from a cold and rainy February here ;)
[Corion]: choroba: Yeah, you have to find a time for the regular skype (or whatever) meetup, I imagine that's hard
[choroba]: Lanzarote is great!
choroba went there year ago
[Discipulus]: here spring has sprung, so the warm is available without holidays..

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2017-02-22 08:49 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (325 votes). Check out past polls.