Perl RegExp to remove last character from strings

I use SAS (a statistical software) and have to remove last character or the last 1/2 numbers that appear after characters from the string using Perl Regular Expression (which is recognized by SAS).

Input: f183ii10 f183ii2 f182ii1 f182ii2 f183iim f22ii f22ii11 f22ii12 pmh4 pmhm

Desired Output:f183ii f183ii f182ii1 f182ii2 f183ii f22ii f22ii f22ii pmh pmh

Thanks for your assistance,

OsE

Look at the man for "chop()" function, it does exactly what you want, example :

#!/usr/bin/perl

my $string = 'frog';
my $chr = chop($string);

print "String: $string\n";
print "Char: $chr\n";

this outputs :

you should, of course, removing this part : "print "Char: $chr\n""

Edit : if you want array :

Thanks for taking time to reply and seeing this post.

Following regexps worked best

#removes the last character from all the words of a string
(s/\w\b/ /) )

# replace last number (if it exists) with a space in macro var value

s/\d+\b/ / ;

# removes duplicate words if they exist
s/\s*(\w+\s+)\1/ /) ) ;