Wagner, David --- Senior Programmer Analyst --- WGO wrote:

From: Bret Goodfellow [mailto:[EMAIL PROTECTED]

Okay, I know this has to be simple, but because I am trying to
truncate or remove a special character I've run into a roadblock. Here's what I want to do. $value = "12345)" ; How do I change $value so that the trailing ")" is removed. In otherwords with the given example, how do I manipulate $value so
that its value is "12345"? Please keep in mind that $value may be
variable in length, so I can't use substr($value, 0, 5). Can split
be used to do this? Stumped.

Will there always be non decimal number or it could be easier to pull
all the numbers:

if ( $value =~ /^(\d+)/ ) {
   $value = $1
 }
else {
   printf "Expecting a numeric field, but got<%s>\n", $value;
   # now either back to the top of a loop or whatever

 }
 or if always want last character removed:
        chop($value);   # removes last character
Or
        $value = substr($value,0,length($value)-1);

Or

 substr($value, -1, 1) = '';

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to