saintmike has asked for the wisdom of the Perl Monks concerning the following question:
while with use bytes, it falls back to byte semantics:# prints '1' print length("\x{03c5}"), "\n";
Now what if I have a module Foo.pm that does a simple calculation:# prints '2' use bytes; print length("\x{03c5}"), "\n";
and I want to impose use bytes semantics on it without modifying its code? Things likepackage Foo; sub len { return length("\x{03c5}"); } 1;
won't work because use bytes modifies the behaviour in its lexical scope. Ideas, anyone?BEGIN { package Foo; use bytes; } use Foo; package main; print Foo::len(), "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: impose 'use bytes' on another package
by ikegami (Patriarch) on Apr 06, 2006 at 06:16 UTC | |
by saintmike (Vicar) on Apr 06, 2006 at 14:29 UTC | |
|
Re: impose 'use bytes' on another package
by codeacrobat (Chaplain) on Apr 05, 2006 at 23:01 UTC | |
by codeacrobat (Chaplain) on Apr 05, 2006 at 23:12 UTC | |
by diotalevi (Canon) on Apr 06, 2006 at 00:42 UTC | |
by codeacrobat (Chaplain) on Apr 06, 2006 at 06:32 UTC | |
by diotalevi (Canon) on Apr 06, 2006 at 14:37 UTC | |
by CountZero (Bishop) on Apr 06, 2006 at 05:40 UTC |