Thanks for the input!
The following is the answer I was looking for and was provided by an Anonymous Monk.
Thank you!
my (%r) = map { $_ => $f{$_} } $left .. $right;
And what I am doing!
"Brain Cell Exercise Project 11"
#!/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 = <STDIN>; chomp $Input; if ( $Input =~ m/^q/ ) { # q to quit last; } printlist $Input, $Input + $Pagelen - 1; }
Ultimately the goal is to page (or line by line) up and down through the list, and enter a number to select a file.
Just have not gotten that far yet.
This is a Brain Cell Exercise so, Any pointers to cleaner, neater, slicker methods would be VERY WELCOME and will be appreciated!
-Enjoy
fh : )_~
In reply to Re: A hash of a range of another hash
by Anonymous Monk
in thread A hash of a range of another hash
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |