--- "F.H" <[EMAIL PROTECTED]> wrote:
> Hi all,

Hi. =o)

> I am trying to skip any line in my input file that doesn't have a
> city with a street named 'MAIN'. I am matching record[3] in my input
> file with a $city (array) from a hash (%state) that I got from
> another file. The problem is that @city contains more than one
> element!

a $city (array) ???

What do you mean?

> while ($line = <INPUT>){
> ....

It might help to see some of the ellipsed code....

> $city = $record[3] ;
> for ($i = 0; $i <=  $#{ $state{$city}; $i ++  ) {  

Never use the
 for( ; ; ) { }
construct in Perl without a significant and compelling reason.
foreach is virtually always better for lots of reasons. Try:

  for my $i ( 0 .. $#{ $state{$city} ) {

>             next if    $state{$city}[$i] ne "MAIN"

Is that next supposed to advance the while loop?
Because I think it's an expensive no-op that just advances the for
loop.

Label the while like this:

  READ: while($line=<INPUT>) {

and then specify which loop is being advanced with

  next READ if ....

>                } 

Hmm...
maybe:
  READ: while($line=<INPUT>) {
        my %lookup = ();
        @lookup{@state{$city}} = 1 .. scalar(@state{$city});
        next READ unless $lookup{MAIN};
        # it's there, so do whatever code...
        
> }

I haven't tested this, and something about it feels funny....
But it's a start. =o)

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Reply via email to