--On Sonntag, 28. Oktober 2001 16:02 -0800 Joe Echavarria <[EMAIL PROTECTED]> wrote:
> Hi there, > > I have a flat file with the follwoing structure : > > city|name|phone|zip. > > The script save each row with "\n" at the end. > > If for example i wish to display all rows of the > cities in Miami. That is city=Miami. It depends on what to do with the found records. For instance, if you wanted to print the phone number for each Miami record together with "Miami": my $phone_pos = 2; my $city_pos = 0; my %city_and_phone; my $file = "whateveryourfilenameis"; open (FILE, "<$file") || die("can't open $file: $!"); while (<FILE>) { my @linearray = split /\|/, $_; if ($linearray[$city_pos] eq "Miami") { $city_and_phone{$linearray[$city_pos]} = $linearray[$phone_pos]; } } close (FILE); foreach my $key (keys %city_and_phone) { print "$key: $city_and_phone{$key}\n"; } Not tested, but I've been using code like this a lot lately. Birgit Kellner -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]