Jair Santos wrote: > > Thank to Mark , Rob and Charles for your help. > > I am using the following snippet of code to check if the directory is empty > and it is working. But I still cannot understand the line my $count = () = > readdir $dh; > > Can anybody explain whats the use of the = ( ) = ?
readdir() returns a list in list context or a scalar in scalar context. In order to get the number of files you have to assign the list from readdir() to an array and then use that array in scalar context to get the number of elements of that array. my @array = readdir $dh; my $count = @array; But perl has a shortcut that allows you to assign a list to () which in scalar context returns the number of elements in the list without having to create an array. # with explicit array my $count = my @array = readdir $dh; # perl shortcut with no array my $count = () = readdir $dh; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]