Avatar of Toraton
Toraton
 asked on

Removing spaces..

Every line of data ends with a carriage return and what looks like a space. I can remove the carriage returns, but how do I remove a space only at the end of the data? if I remove any spaces inside the data, the purpose is lost.Thanks.
Scripting Languages

Avatar of undefined
Last Comment
Ganet

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Tintin

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
shirjeel

Dear Toraton,

I Think you are facing a problem in moving files from windows to unix or linux system. if it is so then the problem is of carriage return. you can use different ways to transfer the files so that you can avoid this problem. like if you are moving files through any ftp software then use ASCII mode it will autmotically remove carriage returns. secondly there is a command too in linux to remove any text from the whole file but i forgot its syntax now.

Shirjeel
SOLUTION
amitabhrai

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SteveFerson

I think you guys should make clear that there is a space in your regex (ie before the $ in tintins and before the * in amitabhrai's)
Ganet

if it is because you are moving the files from windows then windows puts carriage return and line feed together
so try this

$data =~ s/\f//g; # removes line feed characters
$data =~ s/\r//g; # removes carriage return characters
$data =~ s/\n//g; # removes newline characters

assuming you are using $data

this will remove all linefeed, charage return, or new line characters.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck