read() and IO:File->read() error

Discussion in 'Perl Misc' started by Mark H. Siffer, Aug 28, 2003.

  1. I have a file I am reading and when I get to a certain point read() and
    IO::File->read() return undef. I know I have not reached EOF. Is there
    anywhere I can find out why it can't read() or trap an error?

    Thanks in advance
    MS
     
    Mark H. Siffer, Aug 28, 2003
    #1
    1. Advertising

  2. Mark H. Siffer

    Uri Guttman Guest

    >>>>> "MHS" == Mark H Siffer <> writes:

    MHS> I have a file I am reading and when I get to a certain point read() and
    MHS> IO::File->read() return undef. I know I have not reached EOF. Is there
    MHS> anywhere I can find out why it can't read() or trap an error?

    how do you know (better than read()) that you have not reached EOF?

    and actually if you rtfm carefully, EOF is marked with a 0 return, undef
    means an error. so if you really get undef (check with defined) print $!
    and see what the error is.

    uri

    --
    Uri Guttman ------ -------- http://www.stemsystems.com
    --Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
    Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
    Damian Conway Class in Boston - Sept 2003 -- http://www.stemsystems.com/class
     
    Uri Guttman, Aug 28, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. keithb
    Replies:
    2
    Views:
    8,069
    keithb
    Jun 7, 2006
  2. py
    Replies:
    0
    Views:
    689
  3. Replies:
    2
    Views:
    654
    Thomas Matthews
    Feb 27, 2007
  4. Sreejith K
    Replies:
    24
    Views:
    1,087
    Sreejith K
    Mar 24, 2009
  5. Alex Dowad
    Replies:
    4
    Views:
    315
    Michel Demazure
    May 1, 2010
Loading...

Share This Page