Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Adding an new element to array.

by toolic (Bishop)
on Aug 21, 2013 at 15:38 UTC ( [id://1050375]=note: print w/replies, xml ) Need Help??


in reply to Adding an new element to array.

You have a reference to a hash, and you just want to add a new key to the hash:
use warnings; use strict; use Data::Dumper; $Data::Dumper::Sortkeys=1; my $data = { 'DATE' => '2013-04-25', 'TW' => '1', 'REF' => '1234567', 'ACC' => '33456790' }; $data->{DOC} = 'EMAIL'; print Dumper($data); __END__ $VAR1 = { 'ACC' => '33456790', 'DATE' => '2013-04-25', 'DOC' => 'EMAIL', 'REF' => '1234567', 'TW' => '1' };

Replies are listed 'Best First'.
Re^2: Adding an new element to array.
by Anonymous Monk on Aug 21, 2013 at 15:47 UTC
    The data is a array of hashes:
    my @new; foreach my $row (@$data) { push @new, DOC => "EMAIL"}; # } push @$data, @$new;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1050375]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-03-28 23:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found