in reply to Continue block entry

I don't know of any inherent property you could check to see if next had fired. You could set a flag on entry and clear it at the end of the loop block:

my $next_flag; for (@foo) { $next_flag = 1; # my $next_flag = 1; # scope problem # do stuff $next_flag = 0; } continue { warn 'nexted!' if $next_flag; # go on }

Update: Thanks, ikegami, repaired.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: Continue block entry
by prowler (Friar) on May 10, 2005 at 05:56 UTC

    Thanks to both of you for the suggestions, I kind of figured that was likely to be the case, but I was hoping there would be some existing function (or magicly accessible values) with similar information to that provided by caller.

    Prowler
     - Spelling is a demanding task that requies you full attention.

      Perl has an odd feature that you can next out of a block from within a subroutine. Ie:

      sub mynext { next } for (1..10) { mynext(); print $_; }

      This usage will warn as its a form of action at a distance, but it is legal and can be useful*. Thus you could put some caller-fu in mynext() and have it warn where it was called. This would require temporarily s/next/mynext()/g of course so IMO its not a route to be taken lightly. OTOH if its this type of stuff that is causing your problem in the first place then warnings will reveal all. You didnt show any code so its hard to say. :-)

      * An interesting example is its usage in the Test framework for handling SKIP blocks

      ---
      $world=~s/war/peace/g

Re^2: Continue block entry
by ikegami (Patriarch) on May 10, 2005 at 16:54 UTC
    You need to remove the my for that code to work.