Harry wrote:
>> @DirContent = grep { /^[0-9]/ } readdir(DIR);
>> if ($DirContent[0]){

 J. Krahn replied: 
> Again, you are doing boolean tests on the contents of array elements
> when you should really be testing the array itself.  What if
> $DirContent[0] contained the file name "0"?
>
> if ( @DirContent ) {

OK, now I get it.  

> But the test is superfluous because foreach will not loop over an empty 
> array.

Now that seems just wrong ...  Not that it won't loop but that it
doesn't warn or something.

  #!/usr/local/bin/perl -w
  use strict;
  use warnings;
  my @ar = ();
  
  for(@ar){
     print "$_\n";
  }

But running that script just does nothing but gleefully print a
newline.  Maybe there is some reason a programmer would want the above
behavior?


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


Reply via email to