develooper Front page | perl.perl5.porters | Postings from May 2013

[perl #117937] Deprecation warnings in Data::Dumper t/indent.t

Thread Previous
From:
Daniel Macks
Date:
May 11, 2013 09:02
Subject:
[perl #117937] Deprecation warnings in Data::Dumper t/indent.t
Message ID:
rt-3.6.HEAD-6955-1368160164-1754.117937-75-0@perl.org
# New Ticket Created by  Daniel Macks 
# Please include the string:  [perl #117937]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=117937 >


Building Data-Dumper-2.145 on OS X 10.6 using Apple's perl-5.10.0, I get warnings during the self-test:

Use of implicit split to @_ is deprecated at t/indent.t line 100.
Use of implicit split to @_ is deprecated at t/indent.t line 101.
t/indent.t .................... ok

That code-block is:

is(scalar(split("\n" => $dumpstr{ar_indent_2})) + 2,
    scalar(split("\n" => $dumpstr{ar_indent_3})),
    "Indent(3) runs 2 lines longer than Indent(2)");

where the whole apparent goal of the offending scalar(split($pattern => $string)) is to count the occurances of the "\n" character in the string. It doesn't really use the parsed-apart string components at all. So it's an implicit split to @_ but also a somewhat useless one (the @_ results are thrown away). Using OS X 10.7, with Apple's perl-5.12 does not have that warning in indent.t (but using apple's perl-5.10.1 there does). Was this deprecation warning removed from perl?

Simple solutions (which also seem more efficient for what's trying to be accomplished) are found in perlfaq4 ("How can I count the number of occurrences of a substring within a string?"). For example, the following works for me:

is(scalar($dumpstr{ar_indent_2} =~ tr/\n/\n/) + 2,
    scalar($dumpstr{ar_indent_3} =~ tr/\n/\n/),
    "Indent(3) runs 2 lines longer than Indent(2)");

dan

--
Daniel Macks
dmacks@netspace.org


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About