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


I have a problem.

Mumble mumble DOS mumble mumble Windows mumble. Mumble mumble binary mumble. Mumble mumble open file mumble mumble mumble not what I expect mumble mumble mumble. Mumble mumble extra characters mumble mumble or sometimes mumble mumble file truncated.

What do I need to do?

--
John.

Replies are listed 'Best First'.
Re: Mumble file mumble corrupt
by Corion (Patriarch) on Oct 01, 2003 at 10:27 UTC

    I umm like, suggest err mmrrrmhm, binmode - this uh maybe should .. or aah, well, yes I think it should do away with like the file truncation uuuh thing.

    The ... uuuh - hold a minute - ... other thing, those, what do you call them, uh, extra characters, hmmm - like, did you uuh check for UTF-8 or mmrmmhmm Unicode?

    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
Re: Mumble file mumble corrupt
by jmcnamara (Monsignor) on Oct 01, 2003 at 13:00 UTC

    The correct answer is "binmode() the filehandle".

    This kind of question comes up again and again and "binmode() the filehandle" is almost always the right answer. For those who have seen it or suffered from it before some, or all, of the following keywords will prompt the right answer: Windows, binary, file, problem, corrupt.

    Corion for example got the right answer although the question was effectively nonsense.

    So look out for it. It will come up again.

    --
    John.

Re: Mumble file mumble corrupt
by cchampion (Curate) on Oct 01, 2003 at 12:42 UTC
Re: Mumble file mumble corrupt
by thinker (Parson) on Oct 02, 2003 at 14:27 UTC
Re: Mumble file mumble corrupt
by Abigail-II (Bishop) on Oct 01, 2003 at 10:35 UTC
    You didn't use use strict;.

    Abigail

Re: Mumble file mumble corrupt
by wufnik (Friar) on Oct 02, 2003 at 13:55 UTC
    always perilous suggesting non-perl in the monastery particularly when eminent monks have pointed out the uses of binmode but i would use

    od -c mumblefile

    to scan through that mumble-provoking file of yours, then use

    strings mumblefile

    to extract all human readable content. those 2 have worked nicely for me previously on binary & corrupt files.

    there have been rumours strings in particular occasionally yields interesting results when pointed at binary files.

    ermmm, you need cygwin for this, which i presume is already installed, mumble mumble...

    ...wufnik

    -- in the world of the mules there are no rules --
Re: Mumble file mumble corrupt
by Yendor (Pilgrim) on Oct 02, 2003 at 14:26 UTC
Re: Mumble file mumble corrupt
by ViceRaid (Chaplain) on Oct 01, 2003 at 11:00 UTC

    Speak clearly?