in reply to Re: Multiply the numbers in a text file
in thread Multiply the numbers in a text file

Hello edimusrex,

Although loading the file into an array can be done and will work with your data sample, it might encounter memory shortage problem if the input data is very large and it is not very efficient. With a problem such as the one in the original post, it is simpler, more efficient and much safer to read the input file line by line and process each line in turn.

Also the syntax you are proposing (bare word file handles) has been outdated for more than ten years. Look at NetWallah's reply to your post, the syntax in this reply is much more in accordance with the best practices commonly endorsed by the Perl Community these days. Also never open a file without checking if the opening succeeded (or failed).

I almost considered down voting your post for a few seconds, but I did not because the code seems to be correct (I mean workable), and also because you were obviously trying to be helpful. But you should try to use more modern Perl syntax.

Je suis Charlie.
  • Comment on Re^2: Multiply the numbers in a text file

Replies are listed 'Best First'.
Re^3: Multiply the numbers in a text file
by edimusrex (Monk) on May 11, 2015 at 00:33 UTC
    Thanks for the tip. What I've learned in Perl has been taught and learned from some seasoned programmers so it would make sense that I am using "outdated" syntax. I'll take a look at newer standards. I do however always use error checking in production code, just didn't throw it in in my example.