It's terrible code, and I don't even think its working as it should (why set $time to $_1[0] and then replace commas which dont exist in there?)$time=$16; # Time Sample - 1000,000.00 @_1 = split "\,", $16; # Split the value in $16 (should be $time!) + where commas occur, put the results in @_1. (eg 1000 and 000.00) if($#_1 eq 0){ # if there is one value in @_1 (ie no comma +s in $time) $time = int ($time); # set $time to the integer value of $time } if($#_1 eq 1){ # if there are 2 values in @_1 (at least on +e comma) $time=$_1[0]; # set $time to the first value (1000 in my +example) $time=~ s/\,//g; # replace all the commas in $time with noth +ing $time*=1000; # multiply $time by 1000 } if($#_1 eq 2){ $time=1000;} # If there are 3 values in @_1 , set $t +ime to 1000 if($#_1 eq 3){$time=1000;} # If there are 4 values in @_1 , set $t +ime to 1000
I think overall it's trying to parse a number where the thousands are separated by commas, into an integer. I'm sure there are better ways/modules to do that.
C.
In reply to Re: split and compare
by castaway
in thread split and compare
by moked
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |