Hi Wags... So now an idle style question, if you don't mind... This syntax seems pretty obscure to me (I had to look up what printf was doing):
printf "%3d $file\n", $MyId++; It's efficient and all, but isn't this more readable for the same number of characters? print "$MyId $file\n"; $MyId++; I just wondered why you like printf in this circumstance. -Chris -----Original Message----- From: Wagner, David --- Senior Programmer Analyst --- WGO [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 3:36 PM To: McMahon, Chris; [EMAIL PROTECTED] Subject: RE: help building hash on-the-fly? 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]