Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://941945]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2018-03-20 08:23 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (248 votes). Check out past polls.