Are you reading @voltages from a file, by any chance? If so, you probably have newlines at the end of each string. Use chomp to get rid of them.
It's also helpful to print out the value to make sure it is what you think it is:
print "<$voltages[$count]>\n";If you have trailing space or newlines or anything, it will become quite obvious.
Update: A couple of additional thoughts
Instead of ==, use eq, to do a string comparison, even though Perl will numify both arguments.
Do you really just need to find all @voltages that match, exactly, "0.940V"? If so, the simple eq will suffice. If not, the regexp /^(\d+\.\d+)V$/ will match any non-negative floating point voltage, with the number (but not the "V") in $1 if it matched.
Finally, going through the array by number looks a little suspect to me in this case; can you tell us more about what your "processing" entails? There may be a more elegant solution to what you're trying to achieve.
In reply to Re: Trouble matching string with decimals
by rjt
in thread Trouble matching string with decimals
by deshdaaz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |