The above works and I end up with the values swapped, however when the values are swapped a "carriage return" is inserted so the final output ends up spread across two lines, I of course need it to be on one line. Here is an example of my source data.open(INFILE, "iftoportchop"); while(<INFILE>){ @if2port = split /:/,$_; if ($if2port[0] =~ /([1-9]\.\d+)/){ $numvar1 = $1; } open(INFILE2,"portnameok"); LINE2: while(<INFILE2>){ @pnamok = split /:/,$_; if ($pnamok[0] =~ /([1-9]\.\d+)/){ $numvar2 = $1; next LINE2 if $numvar2 > $numvar1; if ($numvar1 eq $numvar2){ open(OUTFILE4, ">> swapnum"); s/$pnamok[0]/$if2port[2]/; print OUTFILE4; } } } }
Below is a sample of the output that I get"iftoportchop" .portIfIndex.3.1 : INTEGER: 377 "portnameok" .portName.3.1 : DISPLAY STRING- (ascii): HX06S24E-CHASSIS1
Whilst looking though Q&A I found a reference to377 : DISPLAY STRING- (ascii): HX06S24E-CHASSIS1
But this has the effect of removing all of the hard returns, which is not what I want. Any Ideas on resolving this problem will be most appreciated. Thanks$var =~ tr/\n/ /;
In reply to swapping values between two files by megatc101
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |