Hi,
I have three functions as below. The two functions get_monthly_data() and get_daily_data() gets Monthly and Daily related data into their respective
Hash array(see the function below). Both the functions has same fields.
All I am trying to do is to merge(append the data from one hash to another hash). Put data from the two hash array of the two functions above into a third hash array.
#!/usr/bin/perl
$monthly_data = get_monthly_data();
$daily_data = get_daily_data();
$merge_data = get_merge_data( $monthly_data , $daily_data )
The $merge_data needs to have data from both $monthly_data , $daily_data
sub get_merge_data
{
How to append data from get_monthly_data() hash array and get_daily_data() hash array into a third Hashand return it from this function.
}
sub get_monthly_data
{
$dbh = DBI->connect("dbi:Oracle:$dbname", .....Database Connectivity......)
$cmd =
q { SELECT DISTINCT
ID, NAME, STATUS, SRC FROM TABLE A };
std = $dbh->prepare("$cmd");
$std->execute;
$hash_return = {};
$node_index=0;
while ( $hash_ref = $std->fetchrow_hashref )
{
push @{$hash_return->{$hash_ref->{'ID'}}}, $hash_ref;
$node_index++;
}
$std->finish;
$dbh->disconnect;
return($hash_return);
}
sub get_daily_data
{
$dbh = DBI->connect("dbi:Oracle:$dbname", .....Database Connectivity......)
$cmd =
q { SELECT DISTINCT
ID, NAME, STATUS, SRC FROM TABLE B };
std = $dbh->prepare("$cmd");
$std->execute;
$hash_return = {};
$node_index=0;
while ( $hash_ref = $std->fetchrow_hashref )
{
push @{$hash_return->{$hash_ref->{'ID'}}}, $hash_ref;
$node_index++;
}
$std->finish;
$dbh->disconnect;
return($hash_return);
}
I have three functions as below. The two functions get_monthly_data() and get_daily_data() gets Monthly and Daily related data into their respective
Hash array(see the function below). Both the functions has same fields.
All I am trying to do is to merge(append the data from one hash to another hash). Put data from the two hash array of the two functions above into a third hash array.
#!/usr/bin/perl
$monthly_data = get_monthly_data();
$daily_data = get_daily_data();
$merge_data = get_merge_data( $monthly_data , $daily_data )
The $merge_data needs to have data from both $monthly_data , $daily_data
sub get_merge_data
{
How to append data from get_monthly_data() hash array and get_daily_data() hash array into a third Hashand return it from this function.
}
sub get_monthly_data
{
$dbh = DBI->connect("dbi:Oracle:$dbname", .....Database Connectivity......)
$cmd =
q { SELECT DISTINCT
ID, NAME, STATUS, SRC FROM TABLE A };
std = $dbh->prepare("$cmd");
$std->execute;
$hash_return = {};
$node_index=0;
while ( $hash_ref = $std->fetchrow_hashref )
{
push @{$hash_return->{$hash_ref->{'ID'}}}, $hash_ref;
$node_index++;
}
$std->finish;
$dbh->disconnect;
return($hash_return);
}
sub get_daily_data
{
$dbh = DBI->connect("dbi:Oracle:$dbname", .....Database Connectivity......)
$cmd =
q { SELECT DISTINCT
ID, NAME, STATUS, SRC FROM TABLE B };
std = $dbh->prepare("$cmd");
$std->execute;
$hash_return = {};
$node_index=0;
while ( $hash_ref = $std->fetchrow_hashref )
{
push @{$hash_return->{$hash_ref->{'ID'}}}, $hash_ref;
$node_index++;
}
$std->finish;
$dbh->disconnect;
return($hash_return);
}