#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; local $SIG{ALRM} = sub { system killall => '1a1.pl'; die }; for my $r (2 .. 20) { SIZE: for my $c (2 .. 20) { open my $OUT, '>', 'x1' or die $!; say {$OUT} 1; say {$OUT} "$r $c"; close $OUT; for my $rand (1 .. 100) { print "$r $c $rand\n"; eval { alarm 1; 0 == system '1a1.pl', $rand, 'x1'; } and do { print "$r $c $rand\n"; next SIZE }; } say "NOT FOUND"; } }