nsheth has asked for the wisdom of the Perl Monks concerning the following question:

Hi
How do i fix the below error:

Can't locate object method "Open" via package "IO::Handle" (perhaps yo +u forgot to load "IO::Handle"?) at C:\Data\Nirmal\perl\clearcase\tt.p +l line 6.
############################################### #!c:\perl\bin use strict; my $file="PCFD\.txt"; Open PFN, "<$file"; my @array = <PFN>; Close PFN; foreach (@array) { print(); }

Thank You

Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips

Replies are listed 'Best First'.
Re: Error:Can't locate object method "Open"
by japhy (Canon) on Jun 09, 2006 at 12:39 UTC
    Perl's functions are case-sensitive. It's spelled open(). The other function is spelled close().

    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

      The rule is perl syntax is case-sensitive.

      When it comes to native perl-functions, they are all lower-case. It makes infinitely more sense to me than that horrible camel-hump BS that Java insists on...

      Thanks a lot....that was fast :)
Re: Error:Can't locate object method "Open"
by Fletch (Bishop) on Jun 09, 2006 at 12:41 UTC

    And a couple of other nits:

    • the three argument form of open is preferred these days
    • always check the return from system calls
    open( PFN, "<", $file ) or die "Can't open '$file': $!\n";
Re: Error:Can't locate object method "Open"
by roboticus (Chancellor) on Jun 09, 2006 at 12:47 UTC
    nsheth:

    I see other monks have already answered your question. But you might want to update your question and add <code> tags around the code to make it simpler to read your question.

    (In common parlance, "Aaargh! My eyes!")</joke>

    --roboticus