Try this approach: (updated) First, add the following lines to one of your scripts, starting at approximately the second line of the script, to test my method:

no warnings 'layers'; use open ':locale'; use warnings 'all';

If that works, then test the following Perl one-liner on another one of your scripts. It will modifiy the script itself.

perl -pi.bak -e "if( $. == 2 ) { $_ = q/no warnings 'layer';\n use ope +n ':locale';\nuse warnings 'all';\n$_/;}" myscript.pl

...where, after testing to make sure it didn't completely wreck "myscript.pl", you go ahead and run that on all the scripts you need modified. The effect will be to add the following line to the 2nd line of each script on which you run the command:

no warnings 'layer'; # This squelches any warning due # to the open pragma not being able to find # a locale definition in your environment # variables. use open ':locale'; # set a default locale for all IO # in your script based on env vars. use warnings 'all';

Please read documentation on the open pragma to understand what is at work here. And PLEASE test this on just one script first; I haven't tested it.


Dave


In reply to Re^3: design the open function by davido
in thread design the open function by singam

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.