my @patterns1 = ('foo') x 2; my @patterns2 = ('bar') x 2; use re 'debug'; while (@patterns1) { 'a' =~ shift @patterns1; 'b' =~ shift @patterns2; } __END__ Compiling REx `foo' size 3 first at 1 1: EXACT (3) 3: END(0) anchored `foo' at 0 (checking anchored isall) minlen 3 Compiling REx `bar' size 3 first at 1 1: EXACT (3) 3: END(0) anchored `bar' at 0 (checking anchored isall) minlen 3 Freeing REx: `foo' Freeing REx: `bar'