in reply to Why can I kind of read this file?

try adding "or die $!" to your open.

cLive ;-)

Replies are listed 'Best First'.
Re: Re: Why can I kind of read this file?
by ichimunki (Priest) on Oct 25, 2001 at 04:57 UTC
    The open is in an if statement. If the open evaluates false (the necessary condition for "or die" to make a difference) the rest of the block following the if should not execute. If the open fails, I want to do something else besides die-- especially since this is a Tk application (in Tk applications all callback errors are trapped, and the application will stay running). On a failed open I put a message to that effect in my status label.

    Further research has indicated that the file is being read, since I can do:
    foreach my $line (<MVMT>) { print $line; }
    and get the results. But if I do:
    my @foo; foreach my $line (<MVMT>) { push( @foo, $line ); } my $file = join('', @foo);
    then $file will be empty where @foo is completely as expected.

    This is a Windows 2000 machine with ActivePerl's latest, if that makes a difference.
      What you are reporting is *extremely* hard to believe. Failing a serious problem with your computer or Perl installation, I would go so far as to call it impossible. Either that or the problem is with some buggy C library that you have loaded which has gone in and edited the Perl data structures behind Perl's back.

      Could you do us a favour and come up with the shortest complete program, along with associated movement file, which demonstrates the failure?

        Well, I can't anymore... that part of the problem is solved. I feel like an idiot for even asking.

        The part here that help was "come up with the shortest complete program... which demonstrates the failure". So, having this file on the drive, I simply wrote the routine afresh and alone in its own .pl and I get it to work, including the eval. So I've brought the working code in and am certain it all works and that my actual bug is farther down and has to do with the complex structure I'm trying to access.

        Thanks to both tilly and cLive for the assistance!