CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Looking for a way to chomp my files

 



neurolou1
New User

Feb 28, 2015, 5:03 PM

Post #1 of 2 (2475 views)
Looking for a way to chomp my files Can't Post

 
Hello I am relatively new to perl when it comes down to functionally using it for specific things. One problem I am having is doing a specific problem that invovles getting rid of new lines within a program.

for instrance, the file has this sort of format.
"
=Rate#1z
321222321231
321222222222
123212312312
=Rate#2z
321312312312
321312312312
231231231231
"

The idea is to get it to look like this
"=Rate#1z32123123123123132312123=Rate#2z3212312312312312"

Now I am trying to rid of the new lines, that way the whole thing can be put in one sign line.
I cant use a chomp option, for an $ARGV[0] option, so I am looking for any suggestions for building an algorithm, any thoughts or suggestions ?


BillKSmith
Veteran

Feb 28, 2015, 8:40 PM

Post #2 of 2 (2447 views)
Re: [neurolou1] Looking for a way to chomp my files [In reply to] Can't Post

It is not possible to edit a file "in place". Refer to perl's -i flag in the document perlrun (type: perldoc perlrun) to see how to simulate this. While you are there, read about the -p flag for easy way to do your processing. Add a -e flag, with a chomp, and your program becomes a very short one-liner.
Good Luck,
Bill

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives