FAQ
In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/06a2b43f40385805090cb01c6d03c30f50de1661?hp=aeefbcf76ce76b270ba3e0bfd3a522940c8a6d00>

- Log -----------------------------------------------------------------
commit 06a2b43f40385805090cb01c6d03c30f50de1661
Author: Jarkko Hietaniemi <jhi@iki.fi>
Date: Mon Mar 7 06:48:23 2016 -0500

     Mention bytes::length modern workaround re 01e331e5

     Also add an emboldening and parabreak to underline the discouragement.

M lib/bytes.pm

commit 1acc81a51d93746bf935d04b06f0508e4d5e92d5
Author: Jarkko Hietaniemi <jhi@iki.fi>
Date: Sun Mar 6 21:23:50 2016 -0500

     Make open failures little less cryptic.

M t/io/through.t
-----------------------------------------------------------------------

Summary of changes:
  lib/bytes.pm | 17 ++++++++++++-----
  t/io/through.t | 4 ++--
  2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/lib/bytes.pm b/lib/bytes.pm
index d871a13..f0022ee 100644
--- a/lib/bytes.pm
+++ b/lib/bytes.pm
@@ -35,13 +35,14 @@ bytes - Perl pragma to expose the individual bytes of characters

  =head1 NOTICE

-
  Because the bytes pragma breaks encapsulation (i.e. it exposes the innards of
  how the perl executable currently happens to store a string), the byte values
-that result are in an unspecified encoding. Use of this module for anything
-other than debugging purposes is strongly discouraged. If you feel that the
-functions here within might be useful for your application, this possibly
-indicates a mismatch between your mental model of Perl Unicode and the current
+that result are in an unspecified encoding.
+
+B<Use of this module for anything other than debugging purposes is
+strongly discouraged.> If you feel that the functions here within
+might be useful for your application, this possibly indicates a
+mismatch between your mental model of Perl Unicode and the current
  reality. In that case, you may wish to read some of the perl Unicode
  documentation: L<perluniintro>, L<perlunitut>, L<perlunifaq> and
  L<perlunicode>.
@@ -108,6 +109,12 @@ C<chr()>, C<ord()>, C<substr()>, C<index()> and C<rindex()> behave similarly.

  For more on the implications, see L<perluniintro> and L<perlunicode>.

+C<bytes::length()> is admittedly handy if you need to know the
+B<byte length> of a Perl scalar. But a more modern way is:
+
+ use Encode 'encode';
+ length(encode('UTF-8', $scalar))
+
  =head1 LIMITATIONS

  C<bytes::substr()> does not work as an I<lvalue()>.
diff --git a/t/io/through.t b/t/io/through.t
index eaf9bc0..e1b3c3c 100644
--- a/t/io/through.t
+++ b/t/io/through.t
@@ -99,7 +99,7 @@ sub testfile ($$$$$$) {
    my @data = grep length, split /(.{1,$write_c})/s, $str;

    my $filename = tempfile();
- open my $fh, '>', $filename or die;
+ open my $fh, '>', $filename or die "open: > $filename: $!";
    select $fh;
    binmode $fh, ':crlf'
        if defined $main::use_crlf && $main::use_crlf == 1;
@@ -115,7 +115,7 @@ sub testfile ($$$$$$) {
      die "Unrecognized write: '$how_w'";
    }
    close $fh or die "close: $!";
- open $fh, '<', $filename or die;
+ open $fh, '<', $filename or die "open: < $filename: $!";
    binmode $fh, ':crlf'
        if defined $main::use_crlf && $main::use_crlf == 1;
    testread($fh, $str, $read_c, $how_r, $write_c, $how_w, "file$why");

--
Perl5 Master Repository

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
groupperl5-changes @
categoriesperl
postedMar 7, '16 at 12:53p
activeMar 7, '16 at 12:53p
posts1
users1
websiteperl.org

1 user in discussion

Jarkko Hietaniemi: 1 post

People

Translate

site design / logo © 2017 Grokbase