... while () { if (/^.*?

.*?( $sw )/) { # first if ... if ( $dec eq "y" ) { # second if ... } # second if CLOSED and DONE WITH } else { ## this was intended to work with second if statement, but now works with the first if ... } ... #### ... while () { if (/^.*?

.*?( $sw )/) { # first if ... if ( $dec eq "y" ) { # second if ... } else { ## NOW else is attached to the second if, and now works as intended ... } } ## END of first if statement. ... #### open my $fh_output,'>>',$output or die "can't open file: $!"; open my $fh_input_file1,'<',$input_file1 or die "can't open file: $!"; open my $fh_input_file2,'<',$input_file2 or die "can't open file: $!"; ... if ( $dec eq "y" ) { print "\nadded \n\n"; ... print $fh_output "$sw \t $_ \n"; } ...