Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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

by sanPerl (Friar)
on May 25, 2007 at 12:29 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-19 13:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found