in reply to Regarding B::Deparse

Be very careful declaring scoped variables in conditionals. In this case, I'd consider the 'for $cond' just as dangerous as 'if $cond'

I've never been able to figure out the rules exactly, but conditional my variables tend to fail in the most bizzare ways. I think B::Deparse is showing you how perl actually unravels that loop, which is also how it should be unraveling it.

Changing

my $i = 1 for $cond;
to
my $i; $i = 1 for $cond;
Should give you the behavior you want.

-jackdied

Replies are listed 'Best First'.
Re: Re: Regarding B::Deparse
by demerphq (Chancellor) on Oct 19, 2001 at 19:22 UTC
    I agree totally. This was a 'far out there' example that I knew had strange funkyness associated with it.

    Personally I think my declarations on the left side of a modifier should result in warnings under warnings, and absolutely my decls on the left side of loop modifiers should produce fatal exception under strict.

    Yves
    --
    You are not ready to use symrefs unless you already know why they are bad. -- tadmc (CLPM)