Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Can I open a specific file (eg. '.log') without knowing the actual name of it?

by Adam (Vicar)
on Apr 07, 2001 at 00:37 UTC ( [id://70597]=note: print w/replies, xml ) Need Help??


in reply to Can I open a specific file (eg. '.log') without knowing the actual name of it?

glob.
use strict; use IO::File; my @logFiles = glob( '*.log' ); my @data; for ( @logFiles ) { # You can further limit your file names thusly: die "Weird File Name" if m/[^a-zA-Z0-9._-]/; my $fh = IO::File->new( '< $_' ) or die "Open Failed for '$_', $!"; push @data, <$fh>; # Do something with the file $fh->close(); }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-03-19 05:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found