#Find the CHAN pair if( $UNID[1] eq $UNID[$x] ) { #Temporary variable to store the CHAN $channel2 = $CHAN[$x]; #Creates a loop counter $y = 1; #Tracks if the changes have been complete $complete = 0; #Search the files for the instancs of the CHAN while( ( $y < scalar( @FILES ) ) && ( $complete == 0 ) ) { #Open the file for replacement open $fd, '<', $FILES[ $y ]; #Creates a backup of the original file $^I = '.bac'; @file = <$fd>; seek $fd, 0, 0; print "$channel1 and $channel2\n"; foreach $file ( @file ) { $file =~ s/$channel2/$channel1/ or die $!; } #Close the file that was searched close $fd; $y++; }#End replacing while #Remove the used entries from the array delete $CHAN[1]; delete $UNID[1]; delete $CHAN[$x]; delete $UNID[$x]; #Force the loop to end $found = 1; }#End pair find if