CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Need help on opening multiple file with same file handle: Edit Log



naven8
Novice

Mar 15, 2012, 1:35 PM


Views: 781
Need help on opening multiple file with same file handle

Hi,

I have written following code and it is working fine. I would like to know whether it is a good thing to do or not?

Code
use warnings; 
use strict;

opendir(my $DH,"/home/xyz") or die "Unable to open $!";
my @Files = readdir($DH);
closedir($DH);

foreach my $Fi (@Files){
open my $FH,'<',$Fi or die "Unable to read $!";
# Do some stuff
close($FH);
}


Is it good? Is there any other good way of doing the same?

Thanks in advance.


(This post was edited by naven8 on Mar 15, 2012, 1:36 PM)


Edit Log:
Post edited by naven8 (Novice) on Mar 15, 2012, 1:36 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives