On 10/21/07, Steven Schubiger <schubiger gmail.com> wrote:
> Ron Koerner <perlbug-followup perl.org> wrote:
>
> > Let aside that this may make no sense the 'last'
in s1 breaks immediately
> > out of the main loop, instead just out of s1 or
even the if-block.
> >
> > The warning comes to late (i.e. when the
counter-intuitive behaviour of
> > last already occured).
>
> For the sake of completeness, consider:
>
> $ perl -MO=Deparse -e 's1(); sub s1 { if (1)
}'
>
> s1();
> sub s1 {
> do {
> 'break'
> };
> }
>
> So `perldoc -f last` advice applies:
>
> ``last cannot be used to exit a block which returns a
value such as eval {} ,
> sub {} or do {} , and should not be used to exit a
grep() or map() operation."
>
> > The documentation suggests that a thing like the
above is not possible or
> > forbidden or breaks out of the if-block, but it
does not give a hint to
> > the current behaviour.
>
> I don't think behaviors which shouldn't be used (and
could be subject to change)
> should be documented at all.
>
> > I don't know if this is a real bug (i.e. last
should do something else)
> > or "just" a documentation bug. If it is
the latter it is not really
> > "dwimmy".
>
> Breaking out of an if compbound block when not nested
within a loop seems
> to me not worthy enough either to be documented.
Did you really mean to say 'break' there? Thats C not Perl.
Cheers,
Yves
--
perl -Mre=debug -e "/just|another|perl|hacker/"
|