[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Simple OpenDir problem



At 12:39 PM -0600 1/24/00, terry chay wrote:
>	What's wrong with this code?
>
>print "Attempting to open current directory" . `pwd` . "...\n";
>opendir(DIR, `pwd`) or die 'cannot open directory';

Try

chomp($dir = `pwd`);
opendir(DIR, $dir) or die 'cannot open directory';

You'll notice that your ellipsis is on a separate line.  `pwd` puts a 
newline at the end, and opendir tries to open that nonexistent 
directory.

>@files = readdir(DIR);
>#closedir(DIR);
>foreach $file (@files) {
>     print("$file\n");
>}
>
>
>	Returns..
>
>Attempting to open current directoryTYikes!:Desktop Folder:Palm 
>installations:showtimes
>...
># cannot open directory.
>File 'TYikes!:Desktop Folder:Palm installations:showtimes:test.pl'; Line 3
>
>	Note, it seems to work fine for ':' and relative pathnames 
>but not for `pwd` or absolute pathnames.
>
>	Thanks!
>
>	terry
>
>chay@uiuc.edu 
>mac:<http://phy290p.physics.uiuc.edu/pgp/eCard.sit.bin>
>terrence y chay homepage:<http://www.pws.uiuc.edu/~tychay/>
>department of physics             pgp 
>key:<http://phy290p.physics.uuc.edu/pgp/>
>university of illinois, urbana-champaign 
>icq:<http://wwp.icq.com/16069322>

--
Paul Schinder
schinder@pobox.com

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org