#!/opt/perl/bin/perl -w # # Simple image list menu # use strict; $| = 1; my $PAGER = ($ENV{'PAGER'} || "more"); $SIG{'PIPE'} = "IGNORE"; scalar(@ARGV) or die "usage: ilm imagelist\n"; open(FILE, $ARGV[0]); my @data = ; close(FILE); while (1) { print "\033[H\033[2J"; open(PIPE, "| $PAGER") or die "Can't execute \`$PAGER': $!\n"; my $i = 1; foreach my $f (@data) { chomp $f; printf PIPE "%3d: %s\n", $i++, $f; } close(PIPE); print "\n Select: "; defined(my $tmp = ) or exit; chomp $tmp; ($tmp !~ /^[\d]+$/ or ($tmp < 1 || $tmp > scalar(@data))) and do {print " Invalid response"; sleep 1; next}; my $f = $data[$tmp - 1]; system("iv '$f'"); } .