in reply to Finding problem with finding keywords in arrays / files
open(INPUT, "data.txt") || die "Error opening 'keywd.txt'\n"; ^^^^----------- wtf? -------------^^^^^
Same here. You use 3 argument open here, you should do the same in the previous open, just to be consistent:
but you'd better write it like with $!open(FH, '<', "keywd.txt") || die "Error opening 'data.txt'\n";
open(FH, '<', "keyword.txt") || die "Error opening 'keyword.txt': $!\n +"; ^^-- sic! error message in here -----------^^
to get the error (No such file, permission denied, ...) along.
You can chomp an entire array
and avoid the chomp($element) further down.chomp(my @data = <INPUT>);
And you do a chomp on $element, but not on the contents of the @keywd array. So, your $element never matches e.g. analysis\n. <update> You require there be a newline in $element - but there isn't one, 'twas chomped off. </update>The other way round there would have been a match.
BTW, your code formatting is pretty messy..
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Finding problem with finding keywords in arrays / files
by akirostar (Novice) on Sep 17, 2006 at 13:31 UTC | |
by shmem (Chancellor) on Sep 17, 2006 at 19:25 UTC |