I have a file with a few lines of text in it. I read each line and put them in an array named @lines :
open FILE, "file.txt";
while(<FILE>) { push @lines,$_; }
close FILE;
Then I want to look for a certain line named "Hello".
my $text = "Hello";
foreach $line (in @lines) {
if ( $text eq $line ) {
print "Hello was found in the document";
}
}
For some reason $text eq $line doesn't work even tho they both contain "Hello".
Can anyone help me with this ?
open FILE, "file.txt";
while(<FILE>) { push @lines,$_; }
close FILE;
Then I want to look for a certain line named "Hello".
my $text = "Hello";
foreach $line (in @lines) {
if ( $text eq $line ) {
print "Hello was found in the document";
}
}
For some reason $text eq $line doesn't work even tho they both contain "Hello".
Can anyone help me with this ?