Jay Kidd wrote:
>
> Hello,
Hello,
> I need help trying to figure out what I'm doing wrong.
> I'm working with 2 seperate text files both of which
> contain domain names. What I'm attempting to do is
> read the first file of domains and run a search based
> on the contents of that file against the second file
> of domains. Then open a completely new file writing
> the contents of the second file with the exception of
> the domains from the first file will be commented out.
>
> Here's an example:
>
> File 1:
> dummy.com
> stupid.com
> idiot.com
> newbie.com
>
> File 2:
> rtfm.com
> readitagain.com
> dummy.com
> stupid.com
> idiot.com
> newbie.com
>
> New File:
> rtfm.com
> readitagain.com
> #dummy.com
> #stupid.com
> #idiot.com
> #newbie.com
>
> [snip]
This will work. It backs up the original file with the extention
'.bak'.
#!/usr/bin/perl -w
use strict;
die "usage: $0 domainlist hostnames\n" unless @ARGV == 2;
my $domainlist = shift;
open DAT, $domainlist or die "Unable to open '$domainlist' $!";
my %domainlist = map { $_ => 1 } <DAT>;
close DAT;
$^I = '.bak';
while ( <> ) {
$domainlist{$_} && s/^/#/;
print;
}
__END__
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]