Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am adding elements to hashes but is not working correctly

Status
Not open for further replies.

spalmarez

IS-IT--Management
Aug 17, 2005
7
US
Looks like I am adding the same information in my hash when they should have different information. How do I just the the information I need?:
14014126,80321.1
14014126,80319.1
14014126,80172.1
13996815,81667.1
13996815,81630.1
13996815,81632.1
13996815,81678.1
13996815,81668.1

Here is my sub:

my $hash= shift;
foreach my $key(keys %hash){
my @response=`mold -obj $key`;
foreach my $rep(@response){
next if ($rep =~ /MCC/);
$rep =~s/preferred//;
$rep =~ s/^\s+$//;
$rep =~ s/^\s+//;
my($mcc,$spf_date,$spf_time,$spf,$dtt_date,$dtt_time,$dtt,$oms) = split (/\s+/,$rep);
$hash{$key}{$mcc}=$mcc++;
}
}
foreach my $test(keys %hash){
print "FIRST ROUND $test\n";
foreach my $mc(keys %{$hash{$test}}){
print "$mc\n";
}
}

Here is my output:

FIRST ROUND 14014126
80321.1
80319.1
80172.1
81667.1
81630.1
81632.1
81678.1
81668.1
FIRST ROUND 13996815
80321.1
80319.1
80172.1
81667.1
81630.1
81632.1
81678.1
81668.1
 
What does the output of the `mold' command look like?
 
This is my initial start (main program).

The first sub I read a file in:

my %hash;

&read_file($moves); ##read file
In my read_file sub I get my data from my file then I put the data into the hash, which works I don't return the hash:

if (defined $_){$hash{$_}++;

----
Here is the sub to get my data.
$hash=&run_oms(\%hash); ##run the my sub to get the data.

 
Here is my mold output:
MCC ODE SPF Time ODE SPF DTT SPF Time DTT SPF OMS state
80319.1 08/20/05 09:12:43 5350 08/19/05 11:01:31 65535 hearing
80321.1 08/19/05 16:59:01 5439 08/19/05 11:01:31 4320 tracking preferred
80172.1 08/19/05 13:26:41 65535 08/19/05 11:01:31 65535 hearing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top