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

Discussion in 'Perl Misc' started by Dave, Jun 11, 2005.

  1. Dave

    Dave Guest

    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
     
    Dave, Jun 11, 2005
    #1
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bret

    char **argv vs. char* argv[]

    Bret, Aug 31, 2003, in forum: C Programming
    Replies:
    21
    Views:
    5,239
    Richard Heathfield
    Sep 3, 2003
  2. David
    Replies:
    10
    Views:
    6,791
    Richard Heathfield
    Sep 15, 2003
  3. Hal Styli
    Replies:
    14
    Views:
    2,083
    Old Wolf
    Jan 20, 2004
  4. =?ISO-8859-1?Q?Thomas_N=FCcker?=

    sys.argv[0] - 'module' object has no attribute 'argv'

    =?ISO-8859-1?Q?Thomas_N=FCcker?=, Jun 30, 2003, in forum: Python
    Replies:
    0
    Views:
    1,537
    =?ISO-8859-1?Q?Thomas_N=FCcker?=
    Jun 30, 2003
  5. jab3

    char **argv & char *argv[]

    jab3, Dec 4, 2004, in forum: C Programming
    Replies:
    5
    Views:
    1,060
    Chris Torek
    Dec 8, 2004
  6. Giles Bowkett
    Replies:
    9
    Views:
    676
    Giles Bowkett
    Dec 17, 2007
  7. gry
    Replies:
    2
    Views:
    1,114
    Alf P. Steinbach
    Mar 13, 2012
  8. Rainer Weikusat

    perlio 'unix' layer file descriptor handling

    Rainer Weikusat, Jan 20, 2013, in forum: Perl Misc
    Replies:
    0
    Views:
    269
    Rainer Weikusat
    Jan 20, 2013
Loading...