#!/usr/bin/perl -w use strict; my $EDITOR = "/usr/bin/less"; my $PATH = "$ENV{HOME}/$ENV{SANDBOX}/examples"; my @files = glob("$PATH/*"); for (@files[($ARGV[0] || 0) .. $#files]) { system($EDITOR, $_); # do $_; # You can do that if you want to... Pun not intended. # Personally, I'd make Next the default... But whatever. =) print "Type [N]EXT to see the next snippet, [Q]UIT to quit,\n", " or any other key to repeat the last snippet: "; my $input = <>; $input =~ /^N/i && next; # or: next if($input =~ /^N/i); $input =~ /^Q/i && last; # or: last if($input =~ /^Q/i); }