in reply to newbie hasher

# assuming you've already opened your file... while (my $line = <FILE>) { chomp $line; my ($host,$ip) = split(/\s+/,$line,2); $hosts{$host} = $ip; }

------------
:Wq
Not an editor command: Wq

Replies are listed 'Best First'.
Re: Re: newbie hasher
by bart (Canon) on Nov 20, 2003 at 21:53 UTC
    Close to perfect, IMO, except that I'd add a test for empty lines, like this:
    my ($host,$ip) = split(/\s+/,$line,2) or next;