You could just use a regex...

$string =~ s/.//;

Or even substr()...

substr($string, 0, 1, '');

Both look equally efficient.

Rob


-----Original Message-----
From: Li, William [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 07, 2003 12:57 PM
To: [EMAIL PROTECTED]
Subject: Chopping off first&last character in a string


Hi,

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"


----------------------------------------------------------------------------
--
This message is intended only for the personal and confidential use of the
designated recipient(s) named above.  If you are not the intended recipient
of
this message you are hereby notified that any review, dissemination,
distribution or copying of this message is strictly prohibited.  This
communication is for information purposes only and should not be regarded as
an offer to sell or as a solicitation of an offer to buy any financial
product, an official confirmation of any transaction, or as an official
statement of Lehman Brothers.  Email transmission cannot be guaranteed to be
secure or error-free.  Therefore, we do not represent that this information
is
complete or accurate and it should not be relied upon as such.  All
information is subject to change without notice.


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

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

Reply via email to