setting perlio layers (e.g., utf8) on "magic" ARGV file handle

D

Dave

I was able to find a few references to similar dilemmas by searching
Google Groups, but none of them fully satisfied my question.

When processing one or more files that have been passed to one's Perl
program from the command line, how does one achieve an effect equivalent
to calling "binmode(FH, ":layer")"? Using "binmode(ARGV)" does not seem
to work for this purpose, because binmode() cannot be called before the
file is open.

As a practical matter, I can use the "C" option on the command line to
workaround this limitation in my present situation, but I would like to
know how to manipulate the layers on the files in @ARGV from within my
program. In addition, the "C" option only controls some of Perl's
Unicode behavior, so it will not always be a viable workaround,
depending on what I'm doing.

I realize that I can of course explicitly open the files myself, but I
can't help but to think that there must exist a more elegant solution
than that.

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top