X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fbytes_heavy.pl;h=923381de58da95b1de3cfee2d2c67102f551d4c8;hb=1f42692825f0c2ae2aff7c8dc9679ad797e3f97c;hp=ec0558561d29f147e9b608ea248c47772ab871dd;hpb=8058d7abf600e878367b422ec507695e4ac6f25a;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/bytes_heavy.pl b/lib/bytes_heavy.pl index ec05585..923381d 100644 --- a/lib/bytes_heavy.pl +++ b/lib/bytes_heavy.pl @@ -1,8 +1,40 @@ -package byte; +package bytes; sub length ($) { - BEGIN { byte::import() } + BEGIN { bytes::import() } return CORE::length($_[0]); } +sub substr ($$;$$) { + BEGIN { bytes::import() } + return + @_ == 2 ? CORE::substr($_[0], $_[1]) : + @_ == 3 ? CORE::substr($_[0], $_[1], $_[2]) : + CORE::substr($_[0], $_[1], $_[2], $_[3]) ; +} + +sub ord ($) { + BEGIN { bytes::import() } + return CORE::ord($_[0]); +} + +sub chr ($) { + BEGIN { bytes::import() } + return CORE::chr($_[0]); +} + +sub index ($$;$) { + BEGIN { bytes::import() } + return + @_ == 2 ? CORE::index($_[0], $_[1]) : + CORE::index($_[0], $_[1], $_[2]) ; +} + +sub rindex ($$;$) { + BEGIN { bytes::import() } + return + @_ == 2 ? CORE::rindex($_[0], $_[1]) : + CORE::rindex($_[0], $_[1], $_[2]) ; +} + 1;