Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Opening multiple log files

by Laurent_R (Canon)
on Jun 15, 2015 at 06:56 UTC ( [id://1130425]=note: print w/replies, xml ) Need Help??


in reply to Opening multiple log files

Hmm, you have this:
for my $filename (@list_files)
running on an uninitialized array, so this for loop will not do anything.

Then you have this:

@output = $timestamp .'.sql'; open(my $fh, '>', @output) or die "Could not create file '@output': $! +";
Filenames should be scalars, not arrays.

Replies are listed 'Best First'.
Re^2: Opening multiple log files
by hahazeeq (Novice) on Jun 15, 2015 at 07:01 UTC
    For the second one I've edited it. But for the for loops is the part where I'm trying to open each file in the directory. I'm guessing that's the wrong way, any ideas how I can fix this? So far I've only been able to open one file but the file name is hard coded. I want to be able to run the script for each file in the directory(each of the files have the same format).

      I suspect you're being distracted by having too much information thrown at you at once.

      Examine just this bit of your code:

      my @list_files; for my $filename (@list_files) { }

      Do you see the problem? You just declared @list_files, so by definition it has nothing in it.

      Your loop therefore has nothing to do.

      Perhaps this will help you see the path forward:

      my @list_files = readdir $dir;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2024-04-18 11:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found