in reply to Re: Another use bytes and length issue
in thread Another use bytes and length issue

If he/she is doing:
SCOPE: { use bytes; $l = length $foo; do_something(); }
Then the scope becomes wider :) bytes will affect anything in do_something()

Replies are listed 'Best First'.
Re^3: Another use bytes and length issue
by ikegami (Patriarch) on Nov 06, 2006 at 23:25 UTC
    Not so.
    sub print_length { my ($s) = @_; print(length($s), "\n"); } my $s = "\x{100}"; print_length($s); # 1 { use bytes; print_length($s); # 1 print(length($s), "\n"); # 2 } print_length($s); # 1
Re^3: Another use bytes and length issue
by BrowserUk (Patriarch) on Nov 06, 2006 at 22:41 UTC

    Use a do block to limit the scope:

    $s = "\x{100}";; print do{ use bytes; length $s } . ' : ' . length $s;; 2 : 1

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^3: Another use bytes and length issue
by dk (Chaplain) on Nov 07, 2006 at 09:11 UTC
    well, duh.
    use bytes; my $s = "\x{100}"; print length $s; { no bytes; print length $s; } print length $s; 2 1 2