CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Win32 Programming Help:
Grep all files in dir!

 



mmcw
User

Aug 12, 2001, 9:58 AM

Post #1 of 2 (2639 views)
Grep all files in dir! Can't Post

I used this code in a sxript on a UNIX machine.

# Read $datafile dir
if (open(DATA,"$datafile")) {
@data = grep(/\.cart/,readdir(DATA));
close(DATA);
}
else {
my_die("Error in subroutine cleanup_user_carts: Can't open $datafile",$!);
}

It worked fine!
Now I try it on a Windows2000 machine and I get a permission denied error.

Can this code not be used on a NT (Windws2000( machine?

When so what code can de used to get a list of all files in a specified dir $datafile with the extension .cart?



mhx
Enthusiast

Aug 12, 2001, 11:25 AM

Post #2 of 2 (2636 views)
Re: Grep all files in dir! [In reply to] Can't Post

open and close are for use with files only. If you want to read directories, use opendir and closedir. Have a look at perldoc -f readdir for an example.

-- Marcus


Code
s$$ab21b8d15c3d97bd6317286d$;$"=547269736;split'i',join$,,map{chr(($*+= 
($">>=1)&1?-hex:hex)+0140)}/./g;$"=chr$";s;.;\u$&;for@_[0,2];print"@_,"


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives