Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
====== 2 - Second script .. doesn't work ============#!/usr/bin/perl use warnings; use strict; use Socket; open (FILE, '>>111.txt'); while (<DATA>) { my $uri = $_; $uri =~ s/\s+//g; my ($name, $aliases, $addrtype, $length, @addrs) = gethostbyna +me $uri; my ($w,$x,$y,$z) = unpack('C4',$addrs[0]); print FILE "$w.$x.$y.$z\n"; } close (FILE); __DATA__ psclxgmprdonx03 totlxfiprdsp502
===== end ======my $dir = 'c:\temp'; my $file = $dir . '/' . 'RH5_CSV_Americas.csv'; open (my $fh, "<", $file) or die $!; ##my @file = <$fh>; open (FILES, '>>111.txt'); while (<$fh>) { my $uri = $_; $uri =~ s/\s+//g; my ($name, $aliases, $addrtype, $length, @addrs) = gethostbyname $uri; my ($w,$x,$y,$z) = unpack('C4',$addrs[0]); print FILES "$w.$x.$y.$z\n"; } close (FILES); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hostname to IP
by choroba (Cardinal) on Nov 06, 2014 at 08:55 UTC | |
|
Re: hostname to IP
by Discipulus (Canon) on Nov 06, 2014 at 14:13 UTC |