Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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; }


Comment on Re: How to implement something similar to Unix's find syntax?
Download Code
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (18)
As of 2015-07-02 13:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (39 votes), past polls