Hi All,
I am writing a script which just diffrenciate the list available in a text file. Following is the script:
#!/usr/local/bin/perl -w
use strict;
use lib qw(/usr/local/bin);
use Time::Local;
my $activebyid = "activtbyid";
my $inactivebyid = "ids.txt";
my @static_nonhuman_strings = qw(
P2P PUR wms sap admin test ftp batch btch client disaster
servere access operator auto java prod webi web
frito ldap user orbit dmart comm pager help
quest ora orb mart db2 con del
dev dmar dnl dpp drobe etm flr hdc
hfp ist ite ncr oms omw page pem
prd pnaf prm psp pt pwm sld slp ssdt
sts tgt wcs wfm wod wpm ziq pp adm mgr
);
sub split_3_ways {
my $filename = shift;
my $tre__aref = shift;
my $ss__href = shift;
my $h__aref = shift;
open FH,"<$filename" || die "\nERROR> Failed opening [$filename] for read access: $!\n";
# Each line has username (only) in it, as:
# username_1
# username_2
# ...
# username_n
USERLINE: while (my $username = <FH>) {
chomp $username;
$username = $1;
# first check for a match against TRE
($username =~ /\w\d[asr]$/) && do {
push @{$tre__aref},$username;
next USERLINE;
};
# second check for a match against the static strings
for my $current_string (@static_nonhuman_strings)
{
($username =~ /$current_string/i) && do {
if (! defined ${$ss__href}{$current_stri
ng}) {
my @anon_array = ();
${$ss__href}{$current_stri
ng} = \@anon_array;
}
push @{$$ss__href{$current_stri
ng}}, $username;
next USERLINE;
};
}
# lastly, username is assumed to be a human
push @{$h__aref},$username;
}
close FH;
} # end split_3_ways
print "\n\nStatic strings:\n";
print "@static_nonhuman_strings\
n";
print "\n\nDetermine if static strings and TRE are mutually exclusive.\n";
print "Do this by checking each static string against Troy's RE:\n";
my $number_of_matches = 0;
for (@static_nonhuman_strings)
{
/\w\d[asr]$/ && do {
print "TRE match [$_]\n";
$number_of_matches++;
next;
};
print "nomatch [$_]\n";
}
print "\n[$number_of_matches] static strings matches TRE.\n\n";
my @tre_ids;
my %ss_ids;
my @h_ids;
@tre_ids = ();
%ss_ids = ();
@h_ids = ();
split_3_ways (
$inactivebyid,
\@tre_ids,
\%ss_ids,
\@h_ids );
open HUMANINACTIVE,">human_inac
tive" or do
{
print "\nERROR> Failed opening human inactive for write access: $!\n";
exit 0;
};
for (sort @h_ids) {
print HUMANINACTIVE "$_\n";
}
close HUMANINACTIVE;
open TREINACTIVE,">TRE_inactive
" or do
{
print "\nERROR> Failed opening TRE inactive for write access: $!\n";
exit 0;
};
for (sort @tre_ids) {
print TREINACTIVE "$_\n";
}
close TREINACTIVE;
open STATICSTRINGSINACTIVE,">st
atic_strin
gs_inactiv
e" or do
{
print "\nERROR> Failed opening static strings inactive for write access: $!\n";
exit 0;
};
I am getting so many warning
Use of uninitialized value in concatenation (.) or string at x line 102.
I also not getting desired result. Its putting whatever in source file that ids.txt into HUMANINACTIVE. Althought there are so many match for the string which is specified in @static_nonhuman_strings.
Is anything wrong with logic?
Hoping for reply .....
Regards,
Pralay Desai
Start Free Trial