in reply to Re^2: Mysteries of unpack("a", ...)
in thread Mysteries of unpack("a", ...)

I use STDIN for command line filters of "catable files" (text), eg. cat or "type" in the Windows world can display those files. I stand corrected about use of a binary file for such a purpose.

I am curious as to what "*_" means? I couldn't find that in my reference books.

The kind of binary files I usually deal with might have an odd number of bytes and I have to fix it up in the final result with either 16 bit aligned or 32 bit aligned values. Sometimes that means shifting things over a byte or more, So something like:
my $n_bytes = read(INBIN, $buff, $BUFSIZE); is the ticket. Your mileage may vary as they say! I haven't written any really hairy binary stuff in Perl.

Replies are listed 'Best First'.
Re^4: Mysteries of unpack("a", ...)
by ikegami (Patriarch) on Jan 03, 2009 at 18:17 UTC

    *_ is the symbol table entry (glob) containing $_ (and @_, %_, etc). Using local on globs is safer than using local on scalars.

    I don't know why you are trying* to prove that read can do something <> can't. I didn't say you shouldn't use read. I didn't say it was useless. I didn't say <> can do everything read can.

    * — You haven't come up with something yet. Keep in mind that length($buff) also returns the number of bytes read.