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

Re: perl deprecated functions and alike

Thread Previous
Octavian Râsnita
February 15, 2009 06:09
Re: perl deprecated functions and alike
Message ID:
From: "Telemachus" <>
> On Sun Feb 15 2009 @  9:45, Octavian Râsnita wrote:
>> From: "John W. Krahn" <>
>>> 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.
>> Can you explain how it works?
>> I have tried the script below, and of course it doesn't print anything:
>> use strict;
>> my $path_to_directory = '/';
>> my @files = <$path_to_directory>;
>> foreach my $file(@files) {
>> print "$file\n";
>> }
>> Thanks.
>> Octavian
> Yup, I'm confused as well. At first, I thought it was the alternative way
> to write glob( $path_to_directory ), but not exactly.
> According to perldoc perlop, @files = <$path_to_directory > (note the 
> extra
> space) will work as a glob, but otherwise, the interpreter thinks that you
> are trying to run readline on an unopened filehandle. Running a short test
> script with 'diagnostics' enabled, I get this:
>  readline() on unopened filehandle $path at files line 7 (#1)
>      (W unopened) An I/O operation was attempted on a filehandle that was
>      never initialized.  You need to do an open(), a sysopen(), or a 
> socket()
>      call, or call a constructor from the FileHandle package.
>     (Are you trying to call readline() on dirhandle $path?)
> So, I would also be curious to know what that construction is supposed to 
> do.
> Thanks, T

I was also thinking to glob and I have also tried using '/*' but it didn't 
I didn't knew that I need to leave an empty space before ">" but with it it 
works fine.


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