HI,

         for  $i (keys %hash) where is %hash ????? or it's %sites

Swayam

----- Original Message ----- From: "The Roopak Times" <[EMAIL PROTECTED]>
To: <beginners@perl.org>
Sent: Tuesday, January 10, 2006 12:54 AM
Subject: How to run a batch file


Hi All

how can i run a batch file by a perl script.
i'm also getting a compilation error in following program. i have output of
ping commnad in a text file and i want to replace the IP Address with the
hostname.

error is:-
Global symbol "%sites " requires explicit package name at network.pl line
25.


#!usr/bin/perl
use warnings;
use strict;

#OPEN THE THE FILE "Check.txt" AND REPLACE IP ADDRESS WITH SITE NAMES

our %sites=(
 '172.16.8.8', "hostname1",
 '172.16.1.8', "hostname2",
 '172.16.4.8', "hostname3",
 '172.16.16.8', "hostname4"
  );

my $i;

open CHECK, ">>'Check.txt'" or die $!;
while (<CHECK>)
 {
 for  $i (keys %hash)
 {
$_ =~ (s/$i/$hash[$i]/g);
 print CHECK $_;
 }
}

--
Thankx & Regards

Roopak Kr Prajapat


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to