develooper Front page | perl.beginners | Postings from February 2009

Re: perl deprecated functions and alike

Thread Previous | Thread Next
Gunnar Hjalmarsson
February 15, 2009 06:19
Re: perl deprecated functions and alike
Message ID:
John W. Krahn wrote:
> Kevin wrote:
>> Could someone please direct me to some web pages where I can go 
>> through all deprecated perl functions and/or ways of writing perl 
>> script?  It is not easy for me to figure out whether an on-line 
>> example is deprecated or not.  I once saw:
>> @files = <$path_to_directory>
>> on the web and found it worked perfectly, then kept using this way of 
>> writing my perl script.  But I was told yesterday such a script is 
>> deprecated now.
> AFAIK that is not deprecated.

Deprecated or not, personally I always use opendir() and readdir().

     opendir my $dir, $path_to_directory or die $!;
     print "$_\n" for grep !/^\./, readdir $dir;
     closedir $dir;

It always 'works', and it's portable.

Gunnar Hjalmarsson

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About