joshclark has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks,
I'm writing a routine that needs to deal with bytes even when the string contains multibyte characters. "use bytes" of course does the trick but would break on pre-5.6 perl (alas, I need to be able to have this run on 5.004+). So, I need to ask the compiler to use the bytes pragma only if it exists...
I *think* this will do the trick but wanted to confirm with those who are wiser than I that I'm not missing anything important here:
BEGIN { eval {require bytes; import bytes; 1} }
Thanks for any advice!
Josh
I'm writing a routine that needs to deal with bytes even when the string contains multibyte characters. "use bytes" of course does the trick but would break on pre-5.6 perl (alas, I need to be able to have this run on 5.004+). So, I need to ask the compiler to use the bytes pragma only if it exists...
I *think* this will do the trick but wanted to confirm with those who are wiser than I that I'm not missing anything important here:
BEGIN { eval {require bytes; import bytes; 1} }
Thanks for any advice!
Josh
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: use bytes without breaking perl 5.005 or 5.004?
by lestrrat (Deacon) on Sep 26, 2003 at 17:12 UTC | |
by tye (Sage) on Sep 26, 2003 at 21:10 UTC | |
by joshclark (Novice) on Sep 28, 2003 at 14:02 UTC | |
by tye (Sage) on Sep 29, 2003 at 03:56 UTC | |
by joshclark (Novice) on Sep 28, 2003 at 13:54 UTC | |
Re: use bytes without breaking perl 5.005 or 5.004?
by bart (Canon) on Sep 27, 2003 at 00:57 UTC |
Back to
Seekers of Perl Wisdom