Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: working with directories

by uday_sagar (Scribe)
on Sep 13, 2013 at 05:26 UTC ( [id://1053840]=note: print w/replies, xml ) Need Help??


in reply to working with directories

Hello,

You can get the same functionality using glob operator(as LaurentR has said) and with fewer lines of code.

Here you go!

#!/usr/bin/perl my @files = glob( "$ARGV[0]/*.*" ); for my $file (@files) { open NB_FILE, '<', $file or die "Couldn't open Netbackup file!"; while(<NB_FILE>) { print "Printing line $. from file $file\n"; print $_; } close NB_FILE or die "Couldn't close the file properly!" }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1053840]
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: (7)
As of 2024-04-26 08:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found