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:
Set file to one line

 



Gregorio
User

May 20, 2001, 5:52 PM

Post #1 of 3 (528 views)
Set file to one line Can't Post

I forget how its done, but how do I set a whole html file that I got to just one line, deleting all of the spaces, tabs and enters, meaning the whole file is one long line.



Mortimer
journeyman

May 20, 2001, 8:46 PM

Post #2 of 3 (521 views)
Re: Set file to one line [In reply to] Can't Post

Tabs and space chars not included yet...


Code
open(FILE,"<$file"); 
while(<FILE>){
print "Before. Line number: $.
";
}
close(FILE);

open(FILE,"+<$file");
while(<FILE>){
chomp;
push(@lines,$_);
}
seek(FILE,0,0);
truncate(FILE,0);
print FILE @lines;
close(FILE);

open(FILE,"<$file");
while(<FILE>){
print "After. Line number: $.
";
}
close(FILE);

Cheers,
Dave.



Gregorio
User

May 21, 2001, 4:23 AM

Post #3 of 3 (515 views)
Re: Set file to one line [In reply to] Can't Post

how would i do this if I was using get to get a file off the internet, and change the html to one line.


 
 


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

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