Skip to content

Instantly share code, notes, and snippets.

@jberger
Created March 9, 2012 18:34
Show Gist options
  • Save jberger/2007924 to your computer and use it in GitHub Desktop.
Save jberger/2007924 to your computer and use it in GitHub Desktop.
On demand PDL::PP via Inline and string eval
#!/usr/bin/env perl
use strict;
use warnings;
use PDL;
my $cond = shift || 0; # can pass a true value as an arg to the script
my $pdl = null();
# sometime later
if ($cond)
{
eval <<'STRING_EVAL';
warn "Compiling";
use Inline Pdlpp => << 'PDLPP';
pp_def('say_hi',
'Pars' => 'a(n)',
'Code' => q{ printf("%s\n", "Hello, world!"); }
);
PDLPP
STRING_EVAL
$pdl->say_hi();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment