On Jan 12, 2008 1:50 PM, <[EMAIL PROTECTED]> wrote: > Rob Dixon <[EMAIL PROTECTED]> writes: > > > which outputs "char<19>". > > > > If you're hoping for something different from this then perhaps you > > would let us know. > > Sorry if I was unclear as to what I was after. Yes that was it. > > > 'bytes' is a pragma, and documentation on it can be retrieved in the > > same way as for all pragma and modules by issuing > > > perldoc bytes > > And the bit about `perldoc bytes' was new ground for me too. > > I never ran into that usage I guess. Or never really thought to look > a `pragma'. > > I thought, right along, that kind of syntax was reserved for pulling > up documentation of a module, like `perldoc File::Find' or whatever. > And have been confused about `pragma' as well. > > You've helped clear that up for me too.... thanks.
Well, a pragma is nothing more than a module that changes the behavior of Perl (as opposed to adding functionality like normal modules). In fact, here is the bytes pragma from Perl 5.8.4 (without the POD): package bytes; our $VERSION = '1.01'; $bytes::hint_bits = 0x00000008; sub import { $^H |= $bytes::hint_bits; } sub unimport { $^H &= ~$bytes::hint_bits; } sub AUTOLOAD { require "bytes_heavy.pl"; goto &$AUTOLOAD; } sub length ($); sub chr ($); sub ord ($); sub substr ($$;$$); sub index ($$;$); sub rindex ($$;$); 1; As you can see it is normal Perl. The real magic happens inside the length and other functions. They check the value of the hints global variable ($^H) and change their behavior if the "use bytes" bit is set. In Perl 5.10 we have been given the ability to (safely) write our own pragmas, see http://perldoc.perl.org/perlpragma.html for more information, or if you have 5.10 installed you can say perldoc perlpragma. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/