in reply to Any way to binmode <>

stupid golf tricks, look at perlop, and perlopentut, what you want to binmode is ARGV, which is what gets open when you use the diamond operator with nothing in between.

update I apologize for being a little rude, but like i say below, you can always <>, binmode, seek, do you thing ;)(who'd have thunk it, in the end, i did know a little something)

UPDATE: well i was almost there, this is kind of stupid, but it'll work as you want it to;

while(<>) { close ARGV; open ARGV, $ARGV or die $!.' '.$ARGV; binmode ARGV; binmode ARGV; local $/; print $_=<>; close BINMODE; }

 
___crazyinsomniac_______________________________________
Disclaimer: Don't blame. It came from inside the void

perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"

Replies are listed 'Best First'.
Re: (crazyinsomniac)Re: Any way to binmode
by bikeNomad (Priest) on Aug 02, 2001 at 19:44 UTC
    I don't think that'll work, as you're free to change @ARGV right up to the first <>. This implies that the ARGV filehandle is not yet open until the first read (which was the point that Thelonius was trying to make).
Re: (crazyinsomniac)Re: Any way to binmode
by Thelonius (Priest) on Aug 02, 2001 at 19:44 UTC
    what you want to binmode is ARGV
    No, that doesn't work, because the binmode needs to be done before the first read.
      *sigh*, here is an example:
      FF: binmode ARGV; while(<>) { print } continue { if(eof) { close ARGV; goto FF; } }

      upate: i apologize, but you can always:

      FF: binmode ARGV; while(<>) { binmode ARGV; local $/; $a=<>; } continue { if(eof) { close ARGV; goto FF; } }

      UPDATE: well i was almost there, this is kind of stupid, but it'll work as you want it to;

      while(<>) { close ARGV; open ARGV, $ARGV or die $!.' '.$ARGV; binmode ARGV; binmode ARGV; local $/; print $_=<>; close BINMODE; }

       
      ___crazyinsomniac_______________________________________
      Disclaimer: Don't blame. It came from inside the void

      perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"

        I know what you're saying, but it just doesn't work... this program:

        use Data::Dumper; $Data::Dumper::Useqq = 1; FF: binmode ARGV; while(<>) { print Dumper($_) } continue { if(eof) { close ARGV; goto FF; } } __END__ this is ctrl-Z:^Z # note: real ctrl-Z there this is past ctrl-z

        produces this output when run on itself under NT (line endings are \r\n):

        /ned $ perl binmode.pl binmode.pl $VAR1 = "use Data::Dumper;\n"; $VAR1 = "\$Data::Dumper::Useqq = 1;\n"; $VAR1 = "\n"; $VAR1 = "FF: binmode ARGV;\n"; $VAR1 = "while(<>)\n"; $VAR1 = "{ print Dumper(\$_) }\n"; $VAR1 = "continue\n"; $VAR1 = "{ if(eof)\n"; $VAR1 = " { close ARGV; goto FF; }\n"; $VAR1 = "}\n"; $VAR1 = "__END__\n"; $VAR1 = "this is ctrl-Z:";