I am working on a program that will act as a contact manager of sorts, it uses two hashes to store everything (although the second one is commented out because I am not ready to work with it). I am using the format function to display everything but I don't know how to get it to show the keys to the hash which is where the names are. Here is my code so far to show what I am talking about:
,----[ CODE ] #!/usr/bin/perl use warnings; use strict; #define hashes my %phone_numbers = (); #my %email_address = (); my $full_name; my $phone_number; print "CSCC Workstudy/Co-Op/Intern Contact Manager\n"; print "Version 0.6\n"; if ("@ARGV" eq 'add') { dbmopen(%phone_numbers, "$ENV{HOME}/phone_numbers", 0766) || die "Can't open database: $!\n"; #Open database for writing print "\nFull Name: "; chomp($full_name = <STDIN>); print "Phone Number: "; chomp($phone_number = <STDIN>); $phone_numbers { $full_name } = $phone_number; dbmclose(%phone_numbers) || die "Can't close database $!\n"; #saves and closes the database exit 0; } elsif ("@ARGV" eq 'view') { dbmopen(%phone_numbers, "$ENV{HOME}/phone_numbers", 0666) || die "Can't open database: $!\n"; #Open database for reading foreach (keys %phone_numbers) { write; } exit 0; } else { die "Usage: $0 [add|view]\n"; } format STDOUT = @<<<<<<<<<<<<<<< @##-###-#### $phone_numbers{$_} #needs to print the keys of the hash for the name, and values for the phone number so it will be like this "Some Name 555-555-5555" . format STDOUT_TOP = Full Name Phone Numbers ========= ============= . `---- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/