if (($line[3] eq ":remove") && (defined $line[4])) { open my $handle1, '<', $srcpath or die "Cant open File: $!"; my @list; my $search = "$line[4]"; print Dumper($search); while (my $x = <$handle1>) { chomp $x; if ($x ne $search) { push @list, $x; print "$x"; }; }; close ($handle1); open my $handle2, '>', $srcpath or die "Cant open File: $!"; foreach my $o (@list) { print $handle2 "$o\n"; }; close($handle2); };