Hi Monks!
I need to merge this data into one dataset, I tried this:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
# This is the dump of a sample data and added to $var1 $var2 $var3
my $var1 = [
{
'date' => '2001-06-04',
'number' => '12345',
'amount' => '100.00',
'status' => 'paid',
'type' => 'new'
},
{
'date' => '2000-001-02',
'number' => 'xc234',
'amount' => '30.88',
'status' => 'new',
'type' => 'cost'
}
];
my $var2 = [
{
'ppay' => 'Smith Doe'
}
];
my $var3 = [
{
'deb1' => '0',
'cred' => '0',
'addr' => '100 - Main Street',
'total' => '250.00 usd',
},
{
'deb1' => '0',
'cred' => '50.14',
'addr' => '1 - Central',
'total' => '51.00',
}
];
my ($data) = {$var1, $var2, $var3};
print Dumper $data;
Result:
Odd number of elements in anonymous hash at merge.pl line 53.
$VAR1 = {
'ARRAY(0x14bd858)' => [
{
'ppay' => 'Smith Doe'
}
],
'ARRAY(0x14cb430)' => undef
};
I am looking for this data dump:
$VAR! = [
{
'date' => '2001-06-04',
'number' => '12345',
'amount' => '100.00',
'status' => 'paid',
'type' => 'new'
},
{
'date' => '2000-001-02',
'number' => 'xc234',
'amount' => '30.88',
'status' => 'new',
'type' => 'cost'
},
{
'ppay' => 'Smith Doe'
},
{
'deb1' => '0',
'cred' => '0',
'addr' => '100 - Main Street',
'total' => '250.00 usd',
},
{
'deb1' => '0',
'cred' => '50.14',
'addr' => '1 - Central',
'total' => '51.00',
}
];
Thanks for the help!
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.