You should probably use eq anyway. If the account numbers can get long then
you risk overflowing what can be stored in numeric format and
having your program perform unexpectedly.
my $f='123456789123456789';
my $g='123456789123456788';
print "g == f\n" if $g == $f;
print "g eq f\n" if $g eq $f;
produces
g == f
Not necessarily the result you want. | [reply] [d/l] [select] |
OK.. another question about this.. kinda...
sub table{
seek(TRACK, 0, 0);
while (<TRACK>){
@trk_data = split(/;/);
}
when I call this subroutine, all my other variables get lost, cause after this call there's more code, then calls to subroutines to print out my data. Those calls work no problems, but when I stick this subroutine call in my main function, all my varialbes/data collected to print get zero'd. (i hope I'm explaining this correctly). All I want to do is read a file, split the data, then later compare the data to other variables collected. If they are in this table, ok... if they are not, to print to this table. Similar problem to my first question. I thought I solved it, but I was wrong yet again!.. .. I also tried using eq as stated before, didn't work. (the numbers are set, size/length of numbers won't change)
... anyone else?
I've done the almost the same thing with another function call, .. opened a file, split it and used the info that I populated into arrays for comparison, and no problem, why one here though?.. is it because I opened up this file for append (>>) ? | [reply] [d/l] |
I don't trust printing to the same filehandle you're reading from. That seems like a good way to get in an infinite loop.
In fact, I wouldn't be surprised if it reset the file pointer, subverting your reads.
My approach to your original issue would be to open the file for reading, make a list of new times to add, close it for reading, open it for appending and append all at once. You would avoid the seek and the possible concurrency issues that way. It's really two conceptual steps anyway, and I couldn't get my test program to handle it correctly the other way anyway.
| [reply] |