On Aug 2, 10:48 am, [EMAIL PROTECTED] (Mihir Kamdar) wrote:

> my $line;
> my %hash;
> my @file;
> my $key ;
> my $value ;
> my %times ;

You appear to be suffering from a nasty case of premature declaration.

Looking at your code it appears that three of those are harmlessly
being declared in the wrong scope.  One is never used.

And most significantly, one is harmfully declared in the wrong scope -
i.e. the fact that you've declared it in the wrong scope will cause
your program to malfunction (assuming I've correctly understood what
you are trying to do).

The remaining one of them may be in the right scope because although
it is mentioned again in your script you never put anything in it so I
can't deduce its intent.

I won't say which is which because you should try to get into the
habit of _always_ declaring _all_ variables in the right scope even on
those occasions where getting it wrong would not actually stop your
program working.

> >                                 while (my $file = readdir $dh1) {
>
> >                                         while ($line=readline($file))

The argument to readline() should be a file handle not a filename.

Note: You should enable warnings and strictures at the top of your
scripts.  I'm note sure, but I suspect, Perl would have found your
mistake for you if you'd let it.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to