| 1 | package bytes;
|
|---|
| 2 |
|
|---|
| 3 | our $VERSION = '1.02';
|
|---|
| 4 |
|
|---|
| 5 | $bytes::hint_bits = 0x00000008;
|
|---|
| 6 |
|
|---|
| 7 | sub import {
|
|---|
| 8 | $^H |= $bytes::hint_bits;
|
|---|
| 9 | }
|
|---|
| 10 |
|
|---|
| 11 | sub unimport {
|
|---|
| 12 | $^H &= ~$bytes::hint_bits;
|
|---|
| 13 | }
|
|---|
| 14 |
|
|---|
| 15 | sub AUTOLOAD {
|
|---|
| 16 | require "bytes_heavy.pl";
|
|---|
| 17 | goto &$AUTOLOAD if defined &$AUTOLOAD;
|
|---|
| 18 | require Carp;
|
|---|
| 19 | Carp::croak("Undefined subroutine $AUTOLOAD called");
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | sub length ($);
|
|---|
| 23 | sub chr ($);
|
|---|
| 24 | sub ord ($);
|
|---|
| 25 | sub substr ($$;$$);
|
|---|
| 26 | sub index ($$;$);
|
|---|
| 27 | sub rindex ($$;$);
|
|---|
| 28 |
|
|---|
| 29 | 1;
|
|---|
| 30 | __END__
|
|---|
| 31 |
|
|---|
| 32 | =head1 NAME
|
|---|
| 33 |
|
|---|
| 34 | bytes - Perl pragma to force byte semantics rather than character semantics
|
|---|
| 35 |
|
|---|
| 36 | =head1 SYNOPSIS
|
|---|
| 37 |
|
|---|
| 38 | use bytes;
|
|---|
| 39 | ... chr(...); # or bytes::chr
|
|---|
| 40 | ... index(...); # or bytes::index
|
|---|
| 41 | ... length(...); # or bytes::length
|
|---|
| 42 | ... ord(...); # or bytes::ord
|
|---|
| 43 | ... rindex(...); # or bytes::rindex
|
|---|
| 44 | ... substr(...); # or bytes::substr
|
|---|
| 45 | no bytes;
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 | =head1 DESCRIPTION
|
|---|
| 49 |
|
|---|
| 50 | The C<use bytes> pragma disables character semantics for the rest of the
|
|---|
| 51 | lexical scope in which it appears. C<no bytes> can be used to reverse
|
|---|
| 52 | the effect of C<use bytes> within the current lexical scope.
|
|---|
| 53 |
|
|---|
| 54 | Perl normally assumes character semantics in the presence of character
|
|---|
|
|---|