![]() |
|
Syntactic Confectionery Delight | |
PerlMonks |
Comparison based on type of value held by variablesby ranjan_jajodia (Monk) |
on Oct 18, 2005 at 13:32 UTC ( #500973=perlquestion: print w/replies, xml ) | Need Help?? |
ranjan_jajodia has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks, I have written a script to match a few columns from two text files. Both the files have records in sorted order; so I just have to read lines from both of them and compare the required column values. However some of the columns are numeric while others are strings. The numeric fields might have leading zeroes so I cannot use string comparison for them. So I have reached a point where I would have to identify the type of value stored in the variables ( which I think I would do by using regex [0-9]+(\.[0-9]+)? ) holding the column values and then compare accordingly. But I think there might be a way to do this context based comparison without getting into all the trouble. I have tried using numerical comparison (using != operator) in all cases but it doesn't work for string values. e.g.
does not print "Not Match". Could you please enlighten me in this regard? Thanks, Ranjan
Back to
Seekers of Perl Wisdom
|
|