I'm writing my first Perl script and am reading a small text file line by line. The fields are delimited by ':' so i want to split each field into a hash array using the first field(name) as the key for each. Also, (I think) I want a big hash that holds all the information, or maybe just an array that holds each field so I can print all info on one line based on a pattern. I've not gotten far as %info is creating odd # elements in the hash assignment. Should I make it a regular array, and am I even going about this the right way? Basically, lines are in this order.
name:phone:address:date:salary
#!/usr/bin/perl -w
use strict;
print $#ARGV;
if($#ARGV == -1)
{
print "Script needs 1 argument please.\n";
exit 1;
}
my $inFILE = $ARGV[0];
#open the file passed
open(IN, "$inFILE") || die "Cannot open: $!"; #open databook.txt
my %info = (my %name, my %phone, my %address, my %date, my %salary);
while(<IN>)
{
%info = (split /:/)[1];
}
close($inFILE);