Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: pushing file counts for adding

by flieckster (Scribe)
on Mar 21, 2016 at 15:18 UTC ( [id://1158444]=note: print w/replies, xml ) Need Help??


in reply to Re: pushing file counts for adding
in thread pushing file counts for adding

what i get now is a document on my desktop named count.txt with all the directory counted files in them. i just want to push that list of integers into another array so i can use it for calculations.

10 28 7 5 3 1 47 7 1 10 11 14 115 2 40 9

Replies are listed 'Best First'.
Re^3: pushing file counts for adding
by Corion (Patriarch) on Mar 21, 2016 at 15:29 UTC

    So, what parts of your program deal with pushing that list into another array, and how do the numbers fail to show up there? Or how are they different from what you expect?

      i was hoping to use PUSH to add the $filecount to a new array.
      print FILE "$filecount\n"; push (@finalcount, @fileslist); $filecount = @finalcount;

        To add it to which array?

        As a general comment, you really should add use strict; use warnings; to the beginning of your script, and make that a practice. It helps identify problems ahead of time.

        Secondly, you are re-using $filecount here and that's confusion waiting to happen. Why not have different variables for the different counts?

        You use the recommended 3 argument form for open once, and then use an obfuscated form to open the second file. Yes, it works as you have it now, but it's trouble waiting to happen. Consistency is your friend. Especially when you revisit a script 6 months later, make what seems to be a no-brainer change, and have to spend too much time figuring out what you broke.

        Code like this with several sections divided by logic ... indenting is a must. If the PM code entry blocks are too clumsy, write in a real editor and copy-and-paste. That helps us figure out what does what.

        This got more preachy than I wanted, but looking back over it there's nothing I feel is extraneous. Perhaps you do all this stuff normally but just wanted to bash out a quick example to ask the question. I would suggest that it is more important, not less, to use good practice here in PM. The bad practices make understanding and helping more difficult.

        But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-28 22:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found