my (%r) = map { $_ => $f{$_} } $left .. $right; #### #!/usr/bin/perl # # BCE Project 11 # use strict; use warnings; my $Directory = '/usr/bin'; # Any directory containing files will do my %Fhash; # Numbered file list hash my @Farray; # Array of found files my $Itemcount = 0; # Count of files found my $File; # my $Pagelen = 20; # Page length (Number of items to print) my $Input; # sub printlist { my %Thash; my $Start = $_[0]; my $End = $_[1]; my $Item; if ($End > $Itemcount) { $End = $Itemcount; } %Thash = map { $_ => $Fhash{$_} } $Start .. $End; foreach $Item (sort{$a <=> $b} keys %Thash) { printf "%s :%s\n", $Item, $Thash{$Item}; } } opendir(DIR, $Directory) || die "can't opendir $Directory: $!"; @Farray = grep { -f "$Directory/$_" } readdir(DIR); closedir DIR; # Create serialized hash of the files... foreach $File (sort sort{$b cmp $a} @Farray) { $Fhash{ ++$Itemcount } = "$Directory/$File"; } print "Itemcount=", $Itemcount, "\n"; while (1) { print "Enter number: "; my $Input = ; chomp $Input; if ( $Input =~ m/^q/ ) { # q to quit last; } printlist $Input, $Input + $Pagelen - 1; }