On Sun, Dec 14, 2008 at 11:36, Anirban Adhikary
<anirban.adhik...@gmail.com> wrote:
> Just write the fiilename as us script and file to open are in same location.
> my $filename="datafile.txt ";
> open my $FH,'<', $filename || die "no such files $!\n";
snip

That needs to be

open my $FH, '<', $filename or die "could not open $filename: $!\n";

|| has to high an order of precedence.  Your code actually does this:

open(my $FH,'<', ($filename || die "no such files $!\n"));

Also, it opens the file in the current working directory, not in the
directory where the script is located.  See the other responses for
the right answer.

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to