Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: The module version works, but the standlone version crashes with "Malformed UTF-8 character"

by choroba (Archbishop)
on Mar 09, 2020 at 21:51 UTC ( #11114049=note: print w/replies, xml ) Need Help??


in reply to The module version works, but the standlone version crashes with "Malformed UTF-8 character"

> perl -CDS

"D" corresponds to "i + o" whose documentation in perlrun states (emphasis mine):

> The "io" options mean that any subsequent open() (or similar I/O operations) in the current file scope will have the ":utf8" PerlIO layer implicitly applied to them, in other words, UTF-8 is expected from any input stream, and UTF-8 is produced to any output stream.

If you put the call to open into a module, it falls out of the current file scope.

The -C is intended for oneliners, in larger programs and modules, use binmode, explicit layers with 3-arg open, or open.pm.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
  • Comment on Re: The module version works, but the standlone version crashes with "Malformed UTF-8 character"
  • Download Code

Replies are listed 'Best First'.
Re^2: The module version works, but the standlone version crashes with "Malformed UTF-8 character"
by Perlfan52 (Novice) on Mar 09, 2020 at 22:15 UTC
    You are right my friend. I must have overseen it. If I start with "perl -CS" instead of "perl -CDS" it works in both versions. I thank you very much.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11114049]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2020-06-03 12:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (23 votes). Check out past polls.

    Notices?