When I open a directory with opendir()
and later call readdir()
two times in a row, the latter returns an empty array.
minimal_example.pl:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper qw(Dumper);
opendir(my $DIRH, "/home") or die "Cannot open /home: $!\n";
my @FILES = readdir($DIRH);
my @FILES2 = readdir($DIRH);
print Dumper \@FILES;
print Dumper \@FILES2;
output:
$VAR1 = [
'.',
'..',
'users',
'sysadmin',
'ne'
];
$VAR1 = [];
Is that expected behavior?