Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

remove space lines from File

Status
Not open for further replies.

PanDa1

Technical User
Nov 1, 2002
5
DE
Hello all,

i am an newbie and try to learn perl. Now i have done my first script an have one problem with a lot of space lines between the text-lines. How can i remove this space-lines
in this file.

thanks PanDa1
 
How are you writing the text to the file? It would probably be easiest to skip writing the blank lines in the first place, rather than editing them out of a file that you created. What does your script look like? Post some code and people will be glad to help.
 
Hello all,

here is the code:

............................................................
#!C:\Perl\bin\perl



$shotech= "d:/Daten/a/b/Configs-Core-Alt/config-origanl.cfg";
$vlanports= "d:/Daten/a/b/Configs-Core-Alt/config-new.txt";


open (SOURCE, "<$shotech");
open (DESTINATION, ">>$vlanports");
@serial=<SOURCE>;

for (@serial, SOURCE){


if (/vlan \d+ ports add /){ # Hier wird angegeben nach was gesucht werden soll und in die Datei geschrieben wird
$_=~s/member portmember$//;
$_=~s/[1-8]\/.[-, ]//g;
$_=~s/^vlan \d+ ports add $//;
$_=~s/^$/!/;
$_=~tr/!//d; # Hier werden die nicht benötigten Ports herausgefiltert.
$_=~s/vlan /config vlan /g;


print "$_\r";
print DESTINATION "$_";

}



if (/perform-tagging/){
$_=~s/^mlt \d+ perform-tagging enable $//;
$_=~s /^$/!/;
$_=~s/ethernet/config ethernet/;



print "$_\r";
# Hier wird das Ergebnis am Bildschirm ausgegeben.
printf DESTINATION "$_"; # Hier wird das Ergebnis in die entsprechende datei gesc

}





}




close (DESTINATION);
close (SOURCE);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top