the letters are hex.
Huh?
So if you have the hex number 7A, you want to retain the 7 and discard the A? That will cause the number 7A, which is 122 in decimal, to become 7 in decimal. Is this really what you want? What you're doing is simply discarding all digits of value greater than nine. ...doesn't make sense to me.
Nevertheless, here's another way to do it..:
$string =~ tr/0-9.//cd;
The /c flag means to complement the characters enumerated on the left side of the tr/// operator. And /d means to delete any character from the target string that is found in the list. /cd means delete any character not found in the list on the lefthand side.
Dave
In reply to Re: data cleaning - removing text from variables
by davido
in thread data cleaning - removing text from variables
by ecuguru
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |