I thought Perl would automatically convert strings to numbers, etc., based on the operator. However, I keep getting a warning message indicating it is confused.
I read a line in from a text file. The line has strings and integers. Everything works fine except the last element in the file is an integer. I'm guessing that since that also has the newline, chomp is making it a string. Then when I do a comparison on this value to a certain number, the warning says I have an uninitialized value at the > sign.
I tried doing a $int_var = $int_var + 0; thinking that would force it to a number but then I get an uninitialized value at + sign.
I took out the chomp command and that didn't help.
Isn't there a simple way to force a string to be an integer?
I'm an old assembly programmer, but I changed my code to $int_val += 0; just to make it better and that seemed to fix the problem. Not sure why but if it works I'm happy.
Thanks for the help.
Steve
Wow, that is odd, I can't seem to recreate the problem (I know issue is solved, but I'm curious). Perl is indeed dynamically and loosely typed.
I even tried:
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)