Skip to content

Instantly share code, notes, and snippets.

@earino
earino / gist:3183917
Created July 26, 2012 19:16
Get the value at the top
my $pm = Parallel::ForkManager->new($PROCESSES);
my @list_of_work = qw/ BLAH BLAH BLAH /;
my @list_of_endpoints = qw/ YADDA YADDA YADDA /;
for my $unit_of_work (@list_of_work) {
my $value_retrieved = retrieve_value_from_stuff($unit_of_work);
my $pid = $pm->start and next;
for my $endpoint (@list_of_endpoints) {
@earino
earino / gist:3183938
Created July 26, 2012 19:19
what your code really looked like
my $pm = Parallel::ForkManager->new($PROCESSES);
my @list_of_work = qw/ BLAH BLAH BLAH /;
my @list_of_endpoints = qw/ YADDA YADDA YADDA /;
for my $unit_of_work (@list_of_work) {
my $pid = $pm->start and next;
for my $endpoint (@list_of_endpoints) {
my $value_retrieved = retrieve_value_from_stuff($unit_of_work, $endpoint);
@earino
earino / gist:3184000
Created July 26, 2012 19:26
Using caching
my $pm = Parallel::ForkManager->new($PROCESSES);
my @list_of_work = qw/ BLAH BLAH BLAH /;
my @list_of_endpoints = qw/ YADDA YADDA YADDA /;
my $cache = CHI->new(
driver => 'FastMmap',
root_dir => $SOME_DIRECTORY,
cache_size => $SIZE,
);
@earino
earino / gist:3630278
Created September 5, 2012 04:13
sample_xml
<?xml version="1.0" standalone="yes"?>
<site>
<regions>
<africa>
<item id="item0">
<location>United States</location>
<quantity>1</quantity>
<name>duteous nine eighteen </name>
<payment>Creditcard</payment>
<description>
@earino
earino / gist:3630337
Created September 5, 2012 04:17
dumper of xml
$VAR1 = {
'people' => {
'person' => {
'homepage' => 'http://www.labs.com/~Tempesti',
'creditcard' => '5048 5813 2703 8253',
'name' => 'Jaak Tempesti',
'id' => 'person0',
'watches' => {
'watch' => {
'open_auction' => 'open_auction0'
@earino
earino / gist:3630374
Created September 5, 2012 04:21
simple XML input
#!/usr/bin/env perl
use warnings;
use strict;
use FindBin;
use File::Slurp;
use XML::Simple;
use Time::HiRes;
@earino
earino / gist:3630393
Created September 5, 2012 04:22
simple with slurp
#!/usr/bin/env perl
use warnings;
use strict;
use FindBin;
use File::Slurp;
use XML::Simple;
use Time::HiRes;
@earino
earino / gist:3630471
Created September 5, 2012 04:31
xml-libxml
#!/usr/bin/env perl
use warnings;
use strict;
use FindBin;
use File::Slurp;
use XML::LibXML;
use Time::HiRes;
@earino
earino / gist:3630540
Created September 5, 2012 04:36
xml-libxml-simple
#!/usr/bin/env perl
use warnings;
use strict;
use FindBin;
use File::Slurp;
use XML::LibXML::Simple qw(XMLin);
use Time::HiRes;
@earino
earino / gist:3630597
Created September 5, 2012 04:41
xml-to-json
#!/usr/bin/env perl
use warnings;
use strict;
use FindBin;
use File::Slurp;
use XML::Simple;
use JSON;
use Time::HiRes;