> -----Original Message----- > From: Konrad Foerstner [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, January 08, 2003 5:25 PM > To: [EMAIL PROTECTED] > Subject: removing emty lines without creating a new file or array > > > Hi, > > My problem today ;) : I have a file with some unmeant empty > lines and I want to remove them, without writing a new file > and without storing all the content temporarily in an array. > I thought about the following lines of code, but they don't > do the job. > > > open (FH, "+<$filename"); > > foreach (<FH>){ > $_ =~ s/^\n//g;
Although you have opened the file in read/write mode, $_ =~ s/^\n//g changes only the content of $_ not the file. You need somehow to remove your empty lines from the file itself. That's here the module Tie::File can elegantly do the job: my @file; tie @file,'Tie::File', $filename or die ... map{ $file[$_]=~s/^\s*$// } (0 .. $#file); HTH, José. > } > > > What's wrong? > > Konrad > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > **** DISCLAIMER **** "This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer". Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]