Mailing List Archive

Undefined dirhandle errors
I received the code included from a contractor. It works under perl 4.036,
but not perl 5.001m.

#!/usr/local/bin/perl

opendir ($handle, ".");
print join (" ", readdir($handle));
closedir ($handle);

The error under perl 5 is:

Bad symbol for filehandle at /home/jared/tmp/test/dirhandle line 3.

If I initialize $handle to an empty string, the code works; are there good
reasons not to have $handle initialized to something valid the first time
it's used in an opendir?

--
jared@organic.com / Organic Online / <URL:http://www.organic.com/Staff/jared/>

"To live is to war with trolls." -- Ibsen