It is Perl reporting an OS message. Consided open F, $foo or die $! say you get permission denied, that is an OS message delivered via perl.

You don't have to use real file descriptors. You could simply open a DBM database or a tied hash, pretend that the keys are the file descriptors and just append to the values. It actually simplifies the code, but it will be a big speed hit.

Here is one of the examples from Re: Binary file handling converted to use a hash tied to a file.

sub rotate_minus90 { my ( $infile, $outfile, $tmp ) = @_; $tmp ||= 'c:/tmp/temp'; open IN, $infile or die "Can't read $infile $!\n"; # find number of columns and open a temp file for each chomp( local $_ = <IN> ); my @data = split ' '; my $num_cols = $#data; dbmopen(my %fhs, $tmp, 0666) or die "dbmopen can't grok $tmp $!\n" +; $fhs{$_} = "$data[$_]\t" for 0..$num_cols; while( <IN> ) { chomp; @data = split ' '; $fhs{$_} .= "$data[$_]\t" for 0..$num_cols; } close IN; open OUT, ">$outfile" or die "Can't write $outfile $!\n"; for ( reverse 0.. $num_cols ) { print OUT $fhs{$_}, "\n"; } dbmclose(%fhs); close OUT; }

cheers

tachyon


In reply to Re: Re:^4 Binary file handling by tachyon
in thread Binary file handling by Hena

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.