Revision history for Perl extension Moose::Autobox
+0.10
+ - add split, words, lines to String (Sartak)
+
0.09 Thu. Oct 23, 2008
- update Perl6::Junction dependency and support new version
sub chop { CORE::chop $_[0] }
sub reverse { CORE::reverse $_[0] }
sub length { CORE::length $_[0] }
+sub lines { CORE::split '\n', $_[0] }
+sub words { CORE::split ' ', $_[0] }
sub index {
return CORE::index($_[0], $_[1]) if scalar @_ == 2;
return CORE::index($_[0], $_[1], $_[2]);
return CORE::rindex($_[0], $_[1]) if scalar @_ == 2;
return CORE::rindex($_[0], $_[1], $_[2]);
}
+sub split {
+ return CORE::split($_[1], $_[0]) if scalar @_ == 2;
+ return CORE::split($_[1], $_[0], $_[2]);
+}
1;
use strict;
use warnings;
-use Test::More tests => 20;
+use Test::More tests => 23;
use Test::Exception;
BEGIN {
is('Hello World, Hello'->rindex('Hello', 6), 0, '... got the correct right index');
+is_deeply(['/foo/bar/baz'->split('/')], ['', 'foo', 'bar', 'baz'], '... got the correct fragments');
+is_deeply(['Hello World'->words], ['Hello', 'World'], '... got the correct words');
+is_deeply(["Hello\nWor\n\nld\n"->lines], ['Hello', 'Wor', '', 'ld'], '... got the correct lines');
+
eval 'Hello World, Hello'->dump;
is($VAR1, 'Hello World, Hello' , '... eval of &dump works');