#!/usr/bin/perl use strict; use warnings; # wait_for_keypress # This script illustrates how to wait for a keypress # Cameron Hayne (macdev@hayne.net) Dec 2002 my $wait_for_keypress = 1; sub wait_for_keypress() { my ($msg) = @_; return unless $wait_for_keypress; print "$msg\n" if $msg; print "Press 'Return' to continue. (Enter \"nowait\" to run free)\n"; my $input = ; $wait_for_keypress = 0 if $input =~ /nowait/; } foreach my $i (1 .. 100) { print "$i\n"; wait_for_keypress(); }