#######Remove power using remove_power_list ########### my $outfile; my $arr_content; my $rprow = join '|', @remove_power_list; $rprow = qr/(?:$rprow)/; if (@remove_power_list != 0) { my $bf_content; open $bf_content, '<', $bf_bind; ###bf_bind is file in bigger for loop my @bf_array = <$bf_content>; close $bf_content; open $outfile, '>', $bf_bind; for $arr_content (@bf_array){ next if (@arr_content=~/$rprow/); print $outfile $arr_content; } close $outfile; }