#!/usr/bin/perl use strict; use warnings; use 5.012; # 927943 # process to run "continuously" from command prompt unless and until I want to enter something... say "\n\t Enter 'i' or 'I' followed by or (only) to interupt;\n\t any other char to continue"; my $NOP = "NoInterupt"; my $i = 1; sub continuous { my $continuous = 1; LABEL: $continuous += $i; $i++; say $continuous; # sleep 1; if ($continuous >= 25 ) { say "continuous >= 25, several iterations completed"; return; } goto LABEL unless ( $NOP ne "NoInterupt") ; } sub T { say "this is from sub T (which ain't doing much, but could be used to deal with an operator input..."; say "for example, try 'R' next time"; return; } sub R { say "About to \"R\" ('run some code')... "; my @foo = qw/foo bar undef 123/; for my $foo(@foo) { say "\t $foo"; } return; } # MAIN START: continuous(); chomp ( my $interupt = <> ); if ( $interupt =~ /[A-H]|[J-Q]|S|[U-Z]/i ) { $NOP = "NoInterupt"; goto START; } elsif ( $interupt =~/r/i ) { R(); $NOP = "R"; goto START; } elsif ( $interupt =~/t/i ) { T(); $NOP="T"; goto START; } elsif ( ($interupt =~/i/i) || ($interupt =~ /''/)) { # exactly 'i' or 'I' or no entry $NOP = "\tSCRAM the reactor!"; say "$NOP, \$i: $i"; } =head execution and output: C:\>927943.pl Enter 'i' or 'I' followed by or (only) to interupt; any other char to continue 2 4 7 11 16 22 29 continuous >= 25, several iterations completed l 9 18 28 continuous >= 25, several iterations completed r About to "R" ('run some code')... foo bar undef 123 12 s 13 26 continuous >= 25, several iterations completed t this is from sub T (which ain't doing much, but could be used to deal with an operator input... for example, try 'R' next time 15 u 16 32 continuous >= 25, several iterations completed i SCRAM the reactor!, $i: 17 C:\> =cut