in reply to Issue getting value from text file and keep decimal

Hello jason.jackal and welcome to the monastery and to the wonderful world of Perl!

Just some general advice for the moment:

Always, and this means ALWAYS use strictures at top of the program:

use strict; use warnings;

If you do not understand messages produced by use warnings you add use diagnostics; and later on commenting it.

Doing so you are forced to declare variables, and doing so you are forced to think about the visibility scope you give them. So;

# $item_date = "DATE"; # becomes my $item_date = "DATE";

Then prefere and use lexical filehandle instead of bareword ones (anyway bareword form is used UPPERCASE). Always put the mode for opening even if < can be omitted. Check if the operation succeded. Always close explicitly your filehandle when you do not need them anymore. So:

# open (file_read, "input-checkbook.txt"); # becomes open my $read, '<', $filepath or die "impossible to read from [$filepa +th]!"; .. close $read;

You can use autodie; if you want to write less.

After all this important things even if not pertinent to your problem.. it is by far better to reduce the code you sumbit for review to isolate the presumed error you encounter..

My time is finished for now..

welcome!

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: Issue getting value from text file and keep decimal
by jason.jackal (Novice) on Jun 30, 2017 at 14:35 UTC
    Thank you for telling me about warnings. This has helped me troubleshoot some of my other scripts that I am tying to build and learn.
Re^2: Issue getting value from text file and keep decimal
by jason.jackal (Novice) on Jun 26, 2017 at 14:48 UTC
    Thank you for your replay. I have not learned about the "my" or strict yet. Why do you need those? I do not understand the concept. Thank you
      take your free copy of ModerPerl the free book and get scope explained at page 80.. but be sure to read pages 1-79 before!

      Read good perl sources to write good code!

      have fun!

      L*

      There are no rules, there are no thumbs..
      Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
        Thank you so much... much appreciate...
      I have not learned about the "my" or strict yet. Why do you need those?

      I think the page Use strict and warnings explains this pretty well.