McMahon, Chris wrote:
> Hello...
>             This is probably a very simple question, but I don't have
> much experience using hashes...
>             I have a simple program that lists all of the files on a
> directory:
> 
> @files = </dir/*>;
> foreach $file (@files) {
>             print "$file\n";
>             }
> 
> which prints something like this:
>             /dir/file1
>             /dir/file2
>             /dir/file3
>             etc.
> 
>             But an array doesn't suit my needs.  What I really need
        You could but why. As part of your print you could do somehting like:
 my $MyId = 1;
 foreach $file (@files) {
             printf "%3d $file\n", $MyId++;
             }
Which should print out just as you want.  

Now the individual can enter say 3, and you can put from @files by subtracting 1 and 
you would have the file.  Using scalar(@files) you now have your Max files within your 
array, so if they enter 6. You subtract 1 and get 5 but scalar(@files) returns 4, you 
know they entered an invalid number.

Just a thought.
Wags ;) 


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to