Well, I think a regex is your best bet.
---
$data = 'This is a very long string ';
$data =~ s/\s+$//;
---
That will trim all trailing spaces.
Without a regex you could try something like
---
$data = 'This is a very long string ';
do {
$_ = $data;
$test = chop;
chop $data unless $test ne " ";
} until ($test ne " ");
---
But I still think the regex is the best way
HTH
John
-----Original Message-----
From: Hamish Whittal [mailto:[EMAIL PROTECTED]]
Sent: 30 August 2001 16:02
To: perl beginners
Subject: removing spaces from the end of a string WITHOUT a REGEX
Hi all,
I have a string I want to remove spaces from but without the use of a
regex.
e.g. 'This is a very long string ', I want to store as 'This is a very
long string'
Notice the removal of 4 spaces at the end. The number of spaces at the
end is variable. If I have to use a regex I will, but there is always
another way of skinning the cat in perl.
Cheers for now.
Hamish
--
This message contains confidential information intended only for the use
of the addressee named above. If you are not the intended recipient of
this message, you are hereby notified that you must not disseminate,
copy or take any action in reliance on it. If you have received this
message in error, please delete it. Any views expressed in this message
are those of the individual sender, except where the sender specifically
states them to be the view of QED Technologies. We aim to provide the
highest degree of security for our customers. Where necessary, all
messages are encrypted, all servers are secured and will henceforth
remain so. If this is an inconvenience to you, we are sorry, but our
business is at stake; a risk we consider no worth taking.
~~
Hamish Whittal QED Technologies Tel: +27 21 448 9291
[EMAIL PROTECTED] Fax: +27 21 448 9551
`The' Linux Services Company Cel: +27 82 803 5533
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------Confidentiality--------------------------.
This E-mail is confidential. It should not be read, copied, disclosed or
used by any person other than the intended recipient. Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful. If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]