in reply to Search and replace on a 130000+ line file.
Here is my quick and nasty solution. This loads the first
file into a hash so it may use up lots of memory. Though
if it too is 130,000 lines that is only a few megabytes.
Should run fast! (Tested also ;-)
use strict; die "Syntax: $0 <names> < djb-file > output-file" unless @ARGV == 1; my %name_to_ip; open(IN, "<".shift) or die; while (<IN>) { chomp; my ($ip, $name) = split /:/; $name_to_ip{$ip} = $name; } close IN or die; while (<>) { chomp; my ($name, $ip) = split /:/; print $name_to_ip{$ip} || $name, ":", $ip, "\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Search and replace on a 130000+ line file.
by sierrathedog04 (Hermit) on May 11, 2001 at 23:05 UTC |
In Section
Seekers of Perl Wisdom