On Tuesday, October 7, 2003, at 11:56 AM, Li, William wrote:

Hi,

Howdy.


Silly question, is there an equal but opposite function to chop in Perl?
I'd like to remove the first and last character of a string and am looking
for a simple way to do it. So far I have:


# "1234567" -> "23456"
chop($string); # "123456"
$string = reverse($string); # "654321"
chop($string); # "65432"
$string = reverse($string); # "23456"

How about an all-in-one try:


$string =~ s/^.(.*).$/$1/;

James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to