in reply to Re: Push values into a hash
in thread Push values into a hash
#!/usr/bin/perl use strict; use warnings; use Data::Dump 'pp'; use Data::Dumper; use JSON; my %data; foreach my $line (<DATA>) { chomp($line); my ($names, $add, $phone, $email) = split/,/, $line; push \%data, { name => $data{name}, address => $data{address}, pho +ne => $data{phone}, email => $data{email} }; } my $json = encode_json \%data; print Dumper $json; __DATA__ Joe, Main Street, 346 20274, test1@test.com Mary, Central Road, 02615128, test2@test.com Lou, Cannal St, 612262297692848, test3@test.com Carl, Sout St, 3268022049187, test4@test.com
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Push values into a hash
by Arunbear (Prior) on Jul 25, 2016 at 16:34 UTC | |
|
Re^3: Push values into a hash
by Anonymous Monk on Jul 25, 2016 at 16:21 UTC | |
|
Re^3: Push values into a hash
by Anonymous Monk on Jul 25, 2016 at 15:34 UTC |