Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: At it again...

by keszler (Priest)
on Dec 06, 2011 at 01:35 UTC ( #941945=note: print w/ replies, xml ) Need Help??


in reply to At it again...

First, kudos for using strict and warnings!

Addressing only the @dump issue mentioned...

You define @dump as a global variable. In the foreach $FileInDirectory(@FileInDirectory) { loop you add "\n\n" to @dump - that would be once per file. Then in the while (<SINGLE>) { loop you add $title and/or $point to @dump each time a line in the file matches the regex.

When you start processing the 2nd file, @dump still contains whatever it got from the 1st. 3rd file, 1st and 2nd, etc. You need to clear out @dump between files. You stated: If I clear the array at each time around, nothing of the list gets written to the OUTPUT. I suspect you added something like @dump = (); after the while (<SINGLE>) { line, clearing it before processing each line of the file. Then, since the last line of the file didn't match, @dump was empty. The fix is to clear the array once per file, not once per line.

. . .

OK, I can't resist this one. You open OUTPUT, print to it, and close it in the while loop. If the file being processed has 172 lines, you're creating that file 172 times.


Comment on Re: At it again...
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (17)
As of 2014-09-02 13:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (22 votes), past polls