Dynamic Hashes
am 30.08.2011 07:40:11 von Vaishak--===============0430952170==
Content-Type: multipart/alternative; boundary=20cf307cfe96fe23b504abb271bd
--20cf307cfe96fe23b504abb271bd
Content-Type: text/plain; charset=ISO-8859-1
Hi All,
Do we have any way to get the Dynamic hash names used? I am able to create
the dynamic hashes, however only gets the dynamic has ref name when
calling
directly. Please see below the code..I wanted to compare the duplicates
records with the .txt files. Not sure if I am doing the right way.
---
@array = ("A.txt", "B.txt", "C.txt");
# these text files are in csv format
#servername,location,ipaddress from where app is accessed
foreach $code (@array){
open(FILE, "$code") || die "Cannot open $code for reading :$!";
while(
next if($_ =~ /ServerName/i);
$line=$_;
my($server,$location,$ip)=split/,/,$line;
$hash{code}{$server}=$line;
#print $hash{code}{$server};
print "\n";
undef $server,$location,$ip;
}
close(FILE);
}
print \%hash;
#foreach $keyname (keys %hash{"A.txt"}){
print;
}
Thanks
VSR
--20cf307cfe96fe23b504abb271bd
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hi All,
any way to get the Dynamic hash names used? I am able to create
=A0 =A0=
the dynamic hashes, however only gets the dynamic has ref name when calling=
=A0 =A0directly. Please see below the code..I wanted to compare the =A0dupl=
icates
=A0 =A0records with the .txt files. Not sure if I am doing the ri=
ght way.
=A0 =A0---
=A0 =A0@array =3D ("A.txt", "B.txt=
", "C.txt");
=A0 =A0# these text files are in csv format
=A0 =A0#servername,location,=
ipaddress from where app is accessed
=A0 =A0foreach $code (@array){
=
=A0 =A0open(FILE, "$code") || die "Cannot open $code for rea=
ding :$!";
=A0 =A0while(<FILE>){
=A0 =A0next if($_ =3D~ /ServerName/i);
=
=A0 =A0$line=3D$_;
=A0 =A0my($server,$location,$ip)=3Dsplit/,/,$line;
>=A0 =A0$hash{code}{$server}=3D$line;
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0#print $hash{code}{$server};
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0print "\n";
=A0 =A0 =A0 =A0 =A0 =A0undef $server,$location,$ip;
=A0 =A0}
=A0 =
=A0close(FILE);
=A0 =A0}
=A0 =A0print \%hash;
=A0 =A0#foreach =
$keyname (keys %hash{"A.txt"}){
=A0 =A0 =A0print;
=A0 =A0}<=
br>
Thanks
>VSR
--20cf307cfe96fe23b504abb271bd--
--===============0430952170==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============0430952170==--