[Denver-pm] short circuiting a loop from a sub?

Robert L. Harris robert.l.harris at gmail.com
Fri Apr 4 13:27:22 PDT 2014


Given this (go for the process flow, not the actual code ) :

$Var[0]="Foo";
$Var[1]="Bar";
$Var[2]="Baz";

foreach $Loop ( @Var ) {
  &CheckOne if ( $Loop =~ /Test1/ );
  &CheckTwo if ( $Loop =~ /Foo/ );
  &CheckThree if ( $Loop =~ /Test3/ );
  &CheckFour if ( $Loop =~ /Test4/ );
  &CheckFive if ( $Loop =~ /Test5/ );
  &CheckSix if ( $Loop =~ /Test6/ );
}

sub CheckTwo {
  # Do some work
}


  There are currently about 15 "Check" sub routines with unique matches
(One $Var will no match multiple sub-procs.  Is there a way so that if I
match on CheckTwo, it will do the equivalent of "next" and go to the next
iteration of the loop instead of walking through the rest of the tests?

  It doesn't seem like much but I'm parsing almost a gig of data regularly
and every check I can skip, the better.

Robert


-- 
:wq!
---------------------------------------------------------------------------
Robert L. Harris

DISCLAIMER:
      These are MY OPINIONS             With Dreams To Be A King,
       ALONE.  I speak for                      First One Should Be A Man
       no-one else.                                     - Manowar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/denver-pm/attachments/20140404/72e51f35/attachment.html>


More information about the Denver-pm mailing list