Here's my solution. There will be shorter ways. I am new to perl, so this is how did it.
At the prompt do $array-prob.pl <datafile> #!/usr/bin/perl #File name : array-prob.pl my @arr; while(<>) { chomp($_); $field{$_}++; print "$_ $field{$_}\n"; my $set = 0; my $reset = 1; foreach $element (@arr) { if($_ ne $element) { $set = 1; } else { $reset = 0; } } if($set == 1 || $arr == 0) { if($reset != 0) { push(@arr,$_); } } } print "\n array - is @arr"; print "\n Repeats are : \n"; foreach $element (@arr) { print "$element was $field{$element} times\n"; } c'ya Aman >From: "Allison Ogle" <[EMAIL PROTECTED]> >To: "a a" <[EMAIL PROTECTED]> >Subject: Array question >Date: Mon, 1 Apr 2002 11:08:00 -0500 > >Hi, > >I have a datafile with a list of names like > >Ana >John >Mike >Tracy >John >Luke >.... >etc. > >I don't know how long the list is and eventually in the list some of the >names will repeat. I want to put these names in an array but I don't want >to repeat any names in the array and I want to keep a count of how many >times the name appears in the list. Does anyone have any ideas or >suggestions? Thanks, > >Allison > > >-- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > _________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]