greenlakers
Technical User
Hi Guys,
I am getting this output from my code:-
TOTAL BulletinID KBID date
3 958439 ABCDEF MS08-074
But I am trying to get this output.
TOTAL BulletinID KBID 2009-01-08 2009-01-09
3 958439 ABCDEF MS08-074 2 1
but i am unable to get the desired output from the code. Can anyone please help?
This is my code:-
#!/usr/local/bin/perl
my @sorted;
$sorted[0] = 'ABCDEF 958439 MS08-074 Security Update for the 2007 Microsoft Office System (KB958439) 2009-01-08';
$sorted[1] = 'FFFFFF 958439 MS08-074 Security Update for the 2007 Microsoft Office System (KB958439) 2009-01-08';
$sorted[2] = 'FFFFFF 958439 MS08-074 Security Update for the 2007 Microsoft Office System (KB958439) 2009-01-09';
my $current = undef;
my $prev = undef;
my %filtered = ();
foreach my $line (@sorted){
my @split = split(/\s/, $line);
if (defined $filtered{$split[1]})
{
substr($filtered{$split[1]},0,1) = (++substr($filtered{$split[1]},0,1));
print "IF $filtered{$split[1]}\n";
if (defined $filtered{$split[12]})
{
substr($filtered{$split[12]},0,1) = (++substr($filtered{$split[12]},0,1));
print "IFIF $filtered{$split[12]}\n";
}
else
{
$filtered{$split[12]} = "1";
print "IFELSE $filtered{$split[12]}\n";
}
}
else {
$filtered{$split[1]} = "1\t$split[1]\t$split[0]\t$split[2]";
print "ELSE $split[1]\n";
print "ELSE $filtered{$split[1]}\n";
$filtered{$split[12]} = "1";
print "ELSE $split[12]\n";
print "ELSE $filtered{$split[12]}\n";
}
}
foreach my $line (values %filtered{$split[1]}){
print "$line\n";
}
print "\n";
I am getting this output from my code:-
TOTAL BulletinID KBID date
3 958439 ABCDEF MS08-074
But I am trying to get this output.
TOTAL BulletinID KBID 2009-01-08 2009-01-09
3 958439 ABCDEF MS08-074 2 1
but i am unable to get the desired output from the code. Can anyone please help?
This is my code:-
#!/usr/local/bin/perl
my @sorted;
$sorted[0] = 'ABCDEF 958439 MS08-074 Security Update for the 2007 Microsoft Office System (KB958439) 2009-01-08';
$sorted[1] = 'FFFFFF 958439 MS08-074 Security Update for the 2007 Microsoft Office System (KB958439) 2009-01-08';
$sorted[2] = 'FFFFFF 958439 MS08-074 Security Update for the 2007 Microsoft Office System (KB958439) 2009-01-09';
my $current = undef;
my $prev = undef;
my %filtered = ();
foreach my $line (@sorted){
my @split = split(/\s/, $line);
if (defined $filtered{$split[1]})
{
substr($filtered{$split[1]},0,1) = (++substr($filtered{$split[1]},0,1));
print "IF $filtered{$split[1]}\n";
if (defined $filtered{$split[12]})
{
substr($filtered{$split[12]},0,1) = (++substr($filtered{$split[12]},0,1));
print "IFIF $filtered{$split[12]}\n";
}
else
{
$filtered{$split[12]} = "1";
print "IFELSE $filtered{$split[12]}\n";
}
}
else {
$filtered{$split[1]} = "1\t$split[1]\t$split[0]\t$split[2]";
print "ELSE $split[1]\n";
print "ELSE $filtered{$split[1]}\n";
$filtered{$split[12]} = "1";
print "ELSE $split[12]\n";
print "ELSE $filtered{$split[12]}\n";
}
}
foreach my $line (values %filtered{$split[1]}){
print "$line\n";
}
print "\n";