I have a script that looped over to get the values $mac and $snr. The result of the loop is as follows
133.3133.5132.9133.1132.9131.8234.4233.7234.7230.3232.3230.8331.9332.0331.6331.6330.9330.2 itd..... 9437.39437.09436.79436.89435.19433.09535.29535.
result from $mac is bolt result form $snr is next
how create %hash where result will be
my %hash = ( mac1 => [’snr1', ‘snr2', ‘snr3', ‘snr4', ‘snr5', ‘snr6'],
mac2 => [’snr1', ‘snr2', ‘snr3', ‘snr4', ‘snr5', ‘snr6'],
mac3 => [’snr1', ‘snr2', ‘snr3', ‘snr4', ‘snr5', ‘snr6'],
);
result with value
my %hash = ( 1 => [’33.3', ‘33.5', ‘32.9', ‘33.1', ‘32.9','31.8' ‘'],
2 => [’34.4', ‘33.7', ‘34.7', ‘30.3', ‘32.3', ‘30.8'],
3 => [’31.9', ‘32.0', ‘31.6', ‘31.6', ‘snr5', ‘snr6'],
);
I can put only part code: I can put only part code:
my $db_snr = DBI->connect("DBI:mysql:$baza:$host", $user, $pass, { RaiseError=>'0', AutoCommit=>'1'} );
if(! $db_snr){
print LOG "Can't connect to mysql serwer at $host, skipping!\n";
exit 0;
}
foreach $upstrim (sort keys %interface){
$typ = $interface{$upstrim}[50];
$mac=$interface{$upstrim}[0];
$mac=~ s/MAC//;
print($snr)
print($mac) # here I woul like create hash witch array
if(($typ eq 'u') && ($mac =~ m/^\d/)){
my $snr = $interface{$upstrim}[30];
if (($snr < 11) && ($snr > 0)) {
print LOG "Test SNR nadajcy $cmts:$mac:$snr:$typ\n";
$db_snr->do("insert into snr values ('$cmts','$mac',NOW(),NOW(),'$snr','1','0','$upstrim') ON DUPLICATE KEY update snr='$snr' ,data_last=NOW(), licznik=licznik+1 ") or warn "Can't prepare: $DBI::errstr";
}
}
}
$db_snr->disconnect;
close(LOG);
133.3133.5132.9133.1132.9131.8234.4233.7234.7230.3232.3230.8331.9332.0331.6331.6330.9330.2 itd..... 9437.39437.09436.79436.89435.19433.09535.29535.? Do you mean to say that all the numbers come mashed together into one long line? Why don't you just show the code you are using?