in reply to simple to describe I/O problem

In addition to the above, your arguments to open are wrong, see IO::File. Try this instead:

... my $fh=IO::File->new; if ($fh->open("$file","<")) { ...

Replies are listed 'Best First'.
Re^2: simple to describe I/O problem
by AnomalousMonk (Archbishop) on Sep 01, 2014 at 19:46 UTC
    if ($fh->open("$file","<")) { ... }

    Why does the string  $file have to be interpolated into another string  "$file" before being passed to the open method?

      It doesn't, "$file" was just a remnant of (too) quickly editing the OP's code. (Unless maybe $file is an object with overloaded stringification; but then it'd probably be stringified inside open...)
Re^2: simple to describe I/O problem
by dottornomade (Initiate) on Sep 01, 2014 at 20:00 UTC

    Thank you.

    My bad, it was a trivial mistake, it works now :)