Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Dynamic File Handles

by cmeyer (Pilgrim)
on Jun 06, 2005 at 20:54 UTC ( [id://464082]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Dynamic File Handles
in thread Dynamic File Handles

Here's a subroutine that will return a hashref, where the keys are the filenames passed in (for those that it is able to open), and the values are filehandles.

updated: removed extraneous "my $fh"

sub open_files { my @files = @_; my %file_handles; for my $file ( @files ) { if ( open my $fh, '<', $file ) { $file_handles{ $file } = $fh; } else { warn "couldn't open $file for reading: $!\n"; } return \%file_handles; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://464082]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 23:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found