"Undocumented feature" of Encode::{en,de}code()

[email protected] (Radoslaw Zielinski)
Newsgroups perl.unicode
Organization independent
Message-ID <20041216122839.GA9176@bongo>
Hello,

What's the point of lines 151 and 167 in Encode.pm?  Respectively:

    # sub encode
    $_[1] = $string if $check;

    # sub decode
    $_[1] = $octets if $check;

I really can't see a point in overwriting the input value...  Why only
"if $check"?  An example of evilness:

  $ perl -MEncode -wle '$x=\"abc"; decode("us-ascii",$$x,1)'
  Modification of a read-only value attempted at /usr/lib/perl5/5.8.6/athlon-pld-linux-thread-multi/Encode.pm line 167.

Besides, the value is empty:

  $ perl -MEncode -we '$x="abc"; decode("us-ascii",$x, 1); print $x' | wc
        0       0       0

-- 
Radosław Zieliński <[email protected]>
[ GPG key: http://radek.karnet.pl/ ]
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFBwX93vesRuUOywuARAnRyAKDotD7fKeWB5zk4DajDTrQsUvGpuQCgpJky
D9xCcMxC3B3FwkNkiJ8Pem4=
=kGna
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.