in reply to Unable to read files from a directory

Have you checked what file this fails on? Your readdir will return the entire contents of the directory, including '.' and '..', which will cause your open to fail. Try modifying

open(MYFILE,"C:/Perl/bin/Anti/$file") or die "Count open file :$!";

to

open(MYFILE,"C:/Perl/bin/Anti/$file") or die "Count open file $file:$!";

and that will uncover your culprit.

In a side note, you have a serious potential security issue by using the two-argument form of open in this context. If there is a maliciously named file in your directory of interest, this script can be made to run arbitrary code.

Replies are listed 'Best First'.
Re^2: Unable to read files from a directory
by GrandFather (Saint) on May 14, 2009 at 03:12 UTC

    I'd go somewhat further than your last paragraph and say:

    Always use the three parameter version of open and use lexical file handles:

    open my $inFile, '<', $filename or die "Unable to open $filename: $!";

    True laziness is hard work
Re^2: Unable to read files from a directory
by antidote1316 (Initiate) on May 14, 2009 at 03:14 UTC
    done ...did that...permission denied at untitled 5 line 7.....I dont understand..I opened all the permissions