Björn Höhrmann: foreach-Anweisung

Beitrag lesen

Ich habe folgendes Problem:

Du führst chomp() nicht aus, somit ist $_ eq "christof\n" und ne "christof".

my $eingabe = 'christof';

open(DATEI, "<mailadress.txt") || die "Datei nicht gefunden";
my @Zeilen = <DATEI>;
close(DATEI);
$gefunden='false';
foreach(@Zeilen) {
  if ($_ eq $eingabe) {
  $gefunden='true';
  }
}

while (chomp($_) = <DATEI>)
{
  $gefunden = 1 if $_ eq $eingabe
}