view release on metacpan or search on metacpan
return undef;
}
return PCX::Loader->new($self,$file);
}
# Crunch a string of words into a map
sub crunch {
my $self = shift;
my @ws = split(/[\s\t]/,shift);
my (@map,$ic);
for my $a (0..$#ws) {
$ic=$self->crunched($ws[$a]);
if(!defined $ic) {
$self->{_crunched}->{list}->[$self->{_crunched}->{_length}++]=$ws[$a];
$map[$a]=$self->{_crunched}->{_length};
} else {
$map[$a]=$ic;
}
}
return \@map;
}
# Finds if a word has been crunched.
# Returns undef on failure, word index for success.
sub crunched {
}
# Alias for crunched(), above
sub word { crunched(@_) }
# Uncrunches a map (array ref) into an array of words (not an array ref)
# and returns array
sub uncrunch {
my $self = shift;
my $map = shift;
my ($c,$el,$x);
foreach $el (@{$map}) {
$c .= $self->{_crunched}->{list}->[$el-1].' ';
}
return $c;
}
# Can also be called as method of your neural net.
# If $high_state_character is null, prints actual numerical values of each element.
sub join_cols {
no strict 'refs';
shift if(substr($_[0],0,4) eq 'AI::');
my $map = shift;
my $break = shift;
my $a = shift;
my $b = shift;
my $x;
foreach my $el (@{$map}) {
my $str = ((int($el))?$a:$b);
$str=$el."\0" if(!$a);
print $str; $x++;
if($x>$break-1) { print "\n"; $x=0; }
}
=item $net->learn($input_map_ref, $desired_result_ref [, options ]);
NOTE: learn_set() now has increment-degrading turned OFF by default. See note
on the degrade flag, below.
This will 'teach' a network to associate an new input map with a desired
result. It will return a string containg benchmarking information.
You can also specify strings as inputs and ouputs to learn, and they will be
crunched automatically. Example:
$net->learn_set(\@data);
Same effect as above, but not the same data (obviously).
=item $net->run($input_map_ref);
This method will apply the given array ref at the input layer of the neural network, and
it will return an array ref to the output of the network. run() will now automatically crunch()
a string given as an input (See the crunch() method for info on crunching).
See also run_uc() and run_set() below.
=item $net->run_uc($input_map_ref);
This method does the same thing as this code:
$net->uncrunch($net->run($input_map_ref));
All that run_uc() does is that it automatically calls uncrunch() on the output, regardless
of whether the input was crunch() -ed or not.
=item $net->crunch($string);
This splits a string passed with /[\s\t]/ into an array ref containing unique indexes
to the words. The words are stored in an intenal array and preserved across load() and save()
calls. This is designed to be used to generate unique maps sutible for passing to learn() and
run() directly. It returns an array ref.
The words are not duplicated internally. For example:
$net->crunch("How are you?");
only once internally and the returned array ref reflects that.
=item $net->uncrunch($array_ref);
Uncrunches a map (array ref) into an scalar string of words seperated by ' ' and returns the
string. This is ment to be used as a counterpart to the crunch() method, above, possibly to
uncrunch() the output of a run() call. Consider the below code (also in ./examples/ex1.pl):
use AI::NeuralNet::Mesh;
my $net = AI::NeuralNet::Mesh->new(2,3);
=item $net->col_width($width);
This is useful for formating the debugging output of Level 4 if you are learning simple
bitmaps. This will set the debugger to automatically insert a line break after that many
elements in the map output when dumping the currently run map during a learn loop.
It will return the current width when called with a 0 or undef value.
The column width is preserved across load() and save() calls.
view all matches for this distribution
view release on metacpan or search on metacpan
examples/eigenvector_initialization.pl view on Meta::CPAN
my @es = list $e; # eigenvalues
# warn "es : ".Dumper \@es;
my @es_desc = sort { $b <=> $a } @es; # eigenvalues sorted desc
# warn "desc: ".Dumper \@es_desc;
my @es_idx = map { _find_num ($_, \@es) } @es_desc; # eigenvalue indices sorted by eigenvalue (desc)
# warn "idx: ".Dumper \@es_idx;
sub _find_num {
my $v = shift;
my $l = shift;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AI/Ollama/Client.pm view on Meta::CPAN
# (but create a copy so we don't over write the input array)
if (my $images = $options{images}) {
# Allow { filename => '/etc/passwd' }
$options{images} = [
map {
my $item = $_;
if( ref($item) eq 'HASH' ) {
$item = Mojo::File->new($item->{filename})->slurp();
};
encode_base64($item)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AI/PBDD.pm view on Meta::CPAN
=over 4
=item B<$pair = createPair($vars_old,$vars_new)>
Create a function C<$pair: BDD variable -E<gt> BDD variable> that maps C<$vars_old-E<gt>[i]> to C<$vars_new-E<gt>[i]>.
=item B<deletePair($pair)>
Free the memory occupied by C<$pair>.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AI/PSO.pm view on Meta::CPAN
this. Also, you may want to take a look at either t/PSO.t for the
simple test or examples/NeuralNetwork/pso_ann.pl for an example on
how to train a simple 3-layer feed forward neural network. (Note
that a real training application would have a real dataset with many
input-output pairs...pso_ann.pl is a _very_ simple example. Also note
that the neural network exmaple requires g++. Type 'make run' in the
examples/NeuralNetwork directory to run the example. Lastly, the
neural network c++ code is in a very different coding style. I did
indeed write this, but it was many years ago when I was striving to
make my code nicely formatted and good looking :)).
view all matches for this distribution
view release on metacpan or search on metacpan
example/PSOTest-MultiCore.pl view on Meta::CPAN
use warnings;
use lib '../lib/';
#-----------------------------------------------------------------------
#use AI::ParticleSwarmOptimization;
use AI::ParticleSwarmOptimization::MCE;
#use AI::ParticleSwarmOptimization::Pmap;
use Data::Dumper; $::Data::Dumper::Sortkeys = 1;
#=======================================================================
sub calcFit {
my @values = @_;
my $offset = int (-@values / 2);
example/PSOTest-MultiCore.pl view on Meta::CPAN
return $sum;
}
#=======================================================================
++$|;
#-----------------------------------------------------------------------
#my $pso = AI::ParticleSwarmOptimization::Pmap->new( # Multi-core
my $pso = AI::ParticleSwarmOptimization::MCE->new( # Multi-core
#my $pso = AI::ParticleSwarmOptimization->new( # Single-core
-fitFunc => \&calcFit,
-dimensions => 10,
-iterations => 10,
example/PSOTest-MultiCore.pl view on Meta::CPAN
my $fitValue = $pso->optimize ();
my ( $best ) = $pso->getBestParticles (1);
my ( $fit, @values ) = $pso->getParticleBestPos ($best);
my $iters = $pso->getIterationCount();
printf "Fit %.4f at (%s) after %d iterations\n", $fit, join (', ', map {sprintf '%.4f', $_} @values), $iters;
warn "\nTime: ", time - $beg, "\n\n";
#=======================================================================
exit 0;
view all matches for this distribution
view release on metacpan or search on metacpan
example/PSOTest-MultiCore.pl view on Meta::CPAN
use warnings;
use lib '../lib/';
#-----------------------------------------------------------------------
#use AI::ParticleSwarmOptimization;
#use AI::ParticleSwarmOptimization::MCE;
use AI::ParticleSwarmOptimization::Pmap;
use Data::Dumper; $::Data::Dumper::Sortkeys = 1;
#=======================================================================
sub calcFit {
my @values = @_;
my $offset = int (-@values / 2);
example/PSOTest-MultiCore.pl view on Meta::CPAN
#=======================================================================
++$|;
#-----------------------------------------------------------------------
#my $pso = AI::ParticleSwarmOptimization->new( # Single-core
#my $pso = AI::ParticleSwarmOptimization::MCE->new( # Multi-core
my $pso = AI::ParticleSwarmOptimization::Pmap->new( # Multi-core
-fitFunc => \&calcFit,
-dimensions => 10,
-iterations => 10,
-numParticles => 1000,
example/PSOTest-MultiCore.pl view on Meta::CPAN
my $fitValue = $pso->optimize ();
my ( $best ) = $pso->getBestParticles (1);
my ( $fit, @values ) = $pso->getParticleBestPos ($best);
my $iters = $pso->getIterationCount();
printf "Fit %.4f at (%s) after %d iterations\n", $fit, join (', ', map {sprintf '%.4f', $_} @values), $iters;
warn "\nTime: ", time - $beg, "\n\n";
#=======================================================================
exit 0;
view all matches for this distribution
view release on metacpan or search on metacpan
Samples/PSOPlatTest.pl view on Meta::CPAN
my ($fit, @values) = $pso->getParticleBestPos ($best);
my $iters = $pso->getIterationCount ();
print $pso->getSeed();
printf ",# Fit %.5f at (%s) after %d iterations\n",
$fit, join (', ', map {sprintf '%.4f', $_} @values), $iters;
sub calcFit {
my @values = @_;
my $offset = int (-@values / 2);
view all matches for this distribution
view release on metacpan or search on metacpan
Benchmark/perl-vs-xs.pl view on Meta::CPAN
use Benchmark qw( timethese cmpthese );
use constant WIDTH_X => 64;
use constant WIDTH_Y => 64;
my @map;
use AI::Pathfinding::AStar::Rectangle;
my $m = AI::Pathfinding::AStar::Rectangle->new({ width => WIDTH_X, heigth => WIDTH_Y });
for my $x (0 .. WIDTH_X - 1 )
{
for my $y (0 .. WIDTH_Y - 1 )
{
$map[$x][$y] = 1;
}
}
$map[5][$_] = 0 for 5 .. WIDTH_Y - 5;
$map[WIDTH_X - 5][$_] = 0 for 5 .. WIDTH_Y - 5;
$map[$_][5] = 0 for 5 .. WIDTH_X - 5;
$map[$_][WIDTH_Y - 5] = 0 for 5 .. WIDTH_X - 10;
$map[$_][10] = 0 for 10 .. WIDTH_X - 10;
$map[WIDTH_X - 10][$_] = 0 for 10 .. WIDTH_Y - 5;
$map[10][$_] = 0 for 10 .. WIDTH_Y - 10;
$map[$_][WIDTH_Y - 10] = 0 for 10 .. WIDTH_X - 15;
$map[WIDTH_X - 15][$_] = 0 for 15 .. WIDTH_Y - 10;
$map[$_][15] = 0 for 15 .. WIDTH_X - 15;
for my $x (0 .. WIDTH_X - 1 )
{
for my $y (0 .. WIDTH_Y - 1 )
{
$m->set_passability($x, $y, $map[$x][$y]) ;
}
}
my ( $x_start, $y_start ) = ( WIDTH_X >> 1, WIDTH_Y >> 1 );
my ( $x_end, $y_end ) = ( 0, 0 );
Benchmark/perl-vs-xs.pl view on Meta::CPAN
}
print "Elapsed: ".tv_interval ( $t0 )."\n";
print "Path length: ".length($path)."\n";
# start end points
$map[ $x_start ][ $y_start ] = 3;
$map[ $x_end ][ $y_end ] = 4;
# draw path
my %vect = (
# x y
1 => [-1, 1, '|/'],
2 => [ 0, 1, '.|'],
Benchmark/perl-vs-xs.pl view on Meta::CPAN
);
my ( $x, $y ) = ( $x_start, $y_start );
for ( split //, $path )
{
$map[$x][$y] = '|o';
$x += $vect{$_}->[0];
$y += $vect{$_}->[1];
$map[$x][$y] = '|o';
}
printf "%02d", $_ for 0 .. WIDTH_X - 1;
print "\n";
for my $y ( 0 .. WIDTH_Y - 1 )
{
for my $x ( 0 .. WIDTH_X - 1 )
{
print $map[$x][$y] eq
'1' ? "|_" : (
$map[$x][$y] eq '0' ? "|#" : (
$map[$x][$y] eq '3' ? "|S" : (
$map[$x][$y] eq '4' ? "|E" : $map[$x][$y] ) ) );
}
print "$y\n";
}
Benchmark/perl-vs-xs.pl view on Meta::CPAN
next if $xn == WIDTH_X ||
$xn < 0 ||
$yn == WIDTH_Y ||
$yn < 0 ||
$close{$xn}{$yn} ||
$map[$xn][$yn] == 0;
my $ng = $g[$x][$y] + $cost{$_};
if ( $open{$xn}{$yn} )
{
if ( $ng < $g[$xn][$yn] )
Benchmark/perl-vs-xs.pl view on Meta::CPAN
{
$x = $x1;
$y = $y1;
$Xend = $x2;
};
$obstacle+=!$map[$x][$y];
$pixel+=5;
while ( $x < $Xend )
{
$x++;
if ($d < 0) {$d += $inc1}
else
{
$y++;
$d += $inc2;
};
$obstacle+=!$map[$x][$y];
$pixel += 5;
};
return ( $obstacle << 3 ) + $pixel;
}
Benchmark/perl-vs-xs.pl view on Meta::CPAN
my ( $x, $y, $xn, $yn, $g) = @_;
for my $j ( 0 .. WIDTH_Y - 1 )
{
for my $i ( 0 .. WIDTH_X - 1 )
{
if ( !$map[$i][$j] )
{
print " ##"
}
else
{
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AI/Pathfinding/AStar.pm view on Meta::CPAN
return $self->SUPER::_init(@_);
}
sub doAStar
{
my ($map, $target, $open, $nodes, $max) = @_;
my $n = 0;
FLOOP: while ( (defined $open->top()) && ($open->top()->{id} ne $target) ) {
#allow incremental calculation
lib/AI/Pathfinding/AStar.pm view on Meta::CPAN
my $curr_node = $open->extract_top();
$curr_node->{inopen} = 0;
my $G = $curr_node->{g};
#get surrounding squares
my $surr_nodes = $map->getSurrounding($curr_node->{id}, $target);
foreach my $node (@$surr_nodes) {
my ($surr_id, $surr_cost, $surr_h) = @$node;
#skip the node if it's in the CLOSED list
next if ( (exists $nodes->{$surr_id}) && (! $nodes->{$surr_id}->{inopen}) );
lib/AI/Pathfinding/AStar.pm view on Meta::CPAN
}
}
sub fillPath
{
my ($map,$open,$nodes,$target) = @_;
my $path = [];
my $curr_node = (exists $nodes->{$target}) ? $nodes->{$target} : $open->top();
while (defined $curr_node) {
unshift @$path, $curr_node->{id};
lib/AI/Pathfinding/AStar.pm view on Meta::CPAN
return $path;
}
sub findPath {
my ($map, $start, $target) = @_;
my $nodes = {};
my $curr_node = undef;
my $open = Heap::Binomial->new;
lib/AI/Pathfinding/AStar.pm view on Meta::CPAN
$curr_node->{h} = 0;
$curr_node->{inopen} = 1;
$nodes->{$start} = $curr_node;
$open->add($curr_node);
$map->doAStar($target,$open,$nodes,undef);
my $path = $map->fillPath($open,$nodes,$target);
return wantarray ? @{$path} : $path;
}
sub findPathIncr {
my ($map, $start, $target, $state, $max) = @_;
my $open = undef;
my $curr_node = undef;;
my $nodes = {};
if (defined($state)) {
lib/AI/Pathfinding/AStar.pm view on Meta::CPAN
$curr_node->{inopen} = 1;
$nodes->{$start} = $curr_node;
$open->add($curr_node);
}
$map->doAStar($target,$open,$nodes,$max);
my $path = $map->fillPath($open,$nodes,$target);
$state = {
'path' => $path,
'open' => $open,
'visited' => $nodes,
'done' => defined($nodes->{$target}),
lib/AI/Pathfinding/AStar.pm view on Meta::CPAN
sub getSurrounding { ... }
package main;
use My::Map::Package;
my $map = My::Map::Package->new or die "No map for you!";
my $path = $map->findPath($start, $target);
print join(', ', @$path), "\n";
#Or you can do it incrementally, say 3 nodes at a time
my $state = $map->findPathIncr($start, $target, undef, 3);
while ($state->{path}->[-1] ne $target) {
print join(', ', @{$state->{path}}), "\n";
$state = $map->findPathIncr($start, $target, $state, 3);
}
print "Completed Path: ", join(', ', @{$state->{path}}), "\n";
=head1 DESCRIPTION
This module implements the A* pathfinding algorithm. It acts as a base class from which a custom map object can be derived. It requires from the map object a subroutine named C<getSurrounding> (described below) and provides to the object two routin...
AI::Pathfinding::AStar requires that the map object define a routine named C<getSurrounding> which accepts the starting and target node ids for which you are calculating the path. In return it should provide an array reference containing the followi...
=over
=item * Node ID
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AI/Pathfinding/OptimizeMultiple.pm view on Meta::CPAN
my $self = shift;
my $args = shift;
my $scans_data = PDL::cat(
map {
my $id = $_->id();
my $pdl = $self->_scans_iters_pdls()->{$id};
my $factor = $self->_stats_factors->{$id};
(
defined($factor)
lib/AI/Pathfinding/OptimizeMultiple.pm view on Meta::CPAN
$self->_status("iterating");
my $iters_quota = 0;
my $flares_num_iters = PDL::Core::pdl( [ (0) x $self->_get_num_scans() ] );
my $ones_constant =
PDL::Core::pdl( [ map { [1] } ( 1 .. $self->_get_num_scans() ) ] );
my $next_num_iters_for_each_scan_x_scan =
( ( $ones_constant x $flares_num_iters ) );
my $num_moves = $self->_scans_data->slice(":,:,1");
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AI/PredictionClient/CPP/PredictionGrpcCpp.pm view on Meta::CPAN
use Inline
CPP => 'DATA',
with => ['Alien::Google::GRPC', 'AI::PredictionClient::Alien::TensorFlowServingProtos'],
version => '0.05',
name => 'AI::PredictionClient::CPP::PredictionGrpcCpp',
TYPEMAPS => getcwd . '/blib/lib/AI/PredictionClient/CPP/Typemaps/more_typemaps_STL_String.txt',
LIBS => '-ldl',
ccflags => '-std=c++11 -pthread';
use 5.010;
use strict;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AI/Prolog.pm view on Meta::CPAN
}
sub list {
my $proto = shift;
return
join ", " => map { /^$RE{num}{real}$/ ? $_ : $proto->quote($_) } @_;
}
sub continue {
my $self = shift;
return 1 unless $self->{_engine}; # we haven't started yet!
view all matches for this distribution
view release on metacpan or search on metacpan
t/annealing_tests.t view on Meta::CPAN
} # end if
# Generate a list of distances for each probability from the data in the
# BSV file:
my $field_names = $bsv_file_reader->get_field_names();
my @mapped_distances; # indexes 2-5 = Probability constants;
# values = references to number arrays
for my $p (2..5) {
$mapped_distances[$p] = [];
} # next $p
unless ($field_names->[0] eq "Time"
&& $field_names->[1] =~ /$Probability::ONE_FIFTH\z/s
&& $field_names->[2] =~ /$Probability::ONE_FOURTH\z/s
t/annealing_tests.t view on Meta::CPAN
} # end if
$dex = $record->{"Time"} - 3;
unless ($dex >= 0
&& $dex <= scalar($mapped_distances[$Probability::ONE_FIFTH])) {
die "ERROR: The input file does not contain market-distance data "
. "in the expected format.\n";
} # end unless
for my $p (2..5) {
push @{ $mapped_distances[$p] }, $record->{$field_names->[6 - $p]};
} # next $p
} # end while
unless (scalar @{ $mapped_distances[$Probability::ONE_FIFTH] } == 61) {
die "ERROR: The input file does not contain the expected number of "
. "records.\n";
} # end unless
# Perform simulated annealing to optimize the coefficients for each of the
# four probabilities, and then print the results to the console:
for my $p (2..5) {
my $cost_function = cost_function_factory($mapped_distances[$p]);
my $optimized_coefficients;
my @number_specs;
push @number_specs,
{"LowerBound" => 0.0, "UpperBound" => 3.0, "Precision" => 3};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AI/TensorFlow/Libtensorflow/ApiDefMap.pm view on Meta::CPAN
my ($xs, $class, @rest) = @_;
$xs->(@rest);
});
$ffi->attach( ['DeleteApiDefMap' => 'DESTROY'] => [
arg 'TF_ApiDefMap' => 'apimap'
] => 'void');
$ffi->attach( [ 'ApiDefMapPut' => 'Put' ] => [
arg 'TF_ApiDefMap' => 'api_def_map',
arg 'tf_text_buffer' => [qw(text text_len)],
arg 'TF_Status' => 'status',
] => 'void' );
$ffi->attach( ['ApiDefMapGet' => 'Get' ] => [
arg 'TF_ApiDefMap' => 'api_def_map',
arg 'tf_text_buffer' => [qw(name name_len)],
arg 'TF_Status' => 'status',
] => 'TF_Buffer');
1;
lib/AI/TensorFlow/Libtensorflow/ApiDefMap.pm view on Meta::CPAN
=head2 New
use AI::TensorFlow::Libtensorflow;
use AI::TensorFlow::Libtensorflow::Status;
my $map = ApiDefMap->New(
AI::TensorFlow::Libtensorflow::TFLibrary->GetAllOpList,
my $status = AI::TensorFlow::Libtensorflow::Status->New
);
ok $map, 'Created ApiDefMap';
B<C API>: L<< C<TF_NewApiDefMap>|AI::TensorFlow::Libtensorflow::Manual::CAPI/TF_NewApiDefMap >>
=head1 METHODS
lib/AI/TensorFlow/Libtensorflow/ApiDefMap.pm view on Meta::CPAN
Get($name, $status)
>>>
=back
my $api_def_buf = $map->Get(
'NoOp',
my $status = AI::TensorFlow::Libtensorflow::Status->New
);
cmp_ok $api_def_buf->length, '>', 0, 'Got ApiDef buffer for NoOp operation';
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AI/Termites/LoginquitasPostulo.pm view on Meta::CPAN
sub before_termites_action {
my $self = shift;
my @ixs = grep !$self->{wood}[$_]{taken}, 0..$#{$self->{wood}};
$self->{kdtree_ixs} = \@ixs;
$self->{kdtree} = Math::Vector::Real::kdTree->new(map $_->{pos}, @{$self->{wood}}[@ixs]);
}
sub termite_take_wood_p {
my ($self, $termite) = @_;
my $pos = $termite->{pos};
view all matches for this distribution
view release on metacpan or search on metacpan
examples/capi_dump_model.pl view on Meta::CPAN
my $dtest = XGDMatrixCreateFromFile('agaricus.txt.test');
my $booster = XGBoosterCreate([$dtrain]);
XGBoosterUpdateOneIter($booster, 1, $dtrain);
my $json_model_with_stats = XGBoosterDumpModelEx($booster, "featmap.txt", 1, "json");
say Dumper $json_model_with_stats;
XGBoosterFree($booster);
XGDMatrixFree($dtrain);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AIIA/GMT.pm view on Meta::CPAN
sub text2entity {
my $txt = shift;
$txt =~ s/\n//g;
my $num;
map {$num++;} split(/\s/, $txt);
die "Usage: &text2entity(\'less than 3000 words\');\n" if ($num > 3000);
return &submit($txt);
}
sub submit {
my @args = (shift);
my $client = Frontier::Client->new(url => $SERVER_URL, debug => 0);
my $ret = $client->call('Annotator.getAnnotation', @args);
my @rep;
map {push @rep, $_->{'offset'} . "\t" . $_->{'mention'};} @{$ret->{'mentions'}};
@rep = sort @rep;
return \@rep;
}
1;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AIX/LVM.pm view on Meta::CPAN
sub get_logical_volumes
{
my $self = shift;
return map {keys %{$self->{$_}->{lvol}}}keys %{$self};
}
sub get_physical_volumes
{
my $self = shift;
return map {keys %{$self->{$_}->{pvol}}}keys %{$self};
}
sub get_volume_group_properties
{
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Devel/CheckLib.pm view on Meta::CPAN
my $exefile = File::Temp::mktemp( 'assertlibXXXXXXXX' ) . $Config{_exe};
my @sys_cmd;
# FIXME: re-factor - almost identical code later when linking
if ( $Config{cc} eq 'cl' ) { # Microsoft compiler
require Win32;
@sys_cmd = (@cc, $cfile, "/Fe$exefile", (map { '/I'.Win32::GetShortPathName($_) } @incpaths));
} elsif($Config{cc} =~ /bcc32(\.exe)?/) { # Borland
@sys_cmd = (@cc, (map { "-I$_" } @incpaths), "-o$exefile", $cfile);
} else { # Unix-ish
# gcc, Sun, AIX (gcc, cc)
@sys_cmd = (@cc, $cfile, (map { "-I$_" } @incpaths), "-o", "$exefile");
}
warn "# @sys_cmd\n" if $args{debug};
my $rv = $args{debug} ? system(@sys_cmd) : _quiet_system(@sys_cmd);
push @missing, $header if $rv != 0 || ! -x $exefile;
_cleanup_exe($exefile);
inc/Devel/CheckLib.pm view on Meta::CPAN
for my $lib ( @libs ) {
my $exefile = File::Temp::mktemp( 'assertlibXXXXXXXX' ) . $Config{_exe};
my @sys_cmd;
if ( $Config{cc} eq 'cl' ) { # Microsoft compiler
require Win32;
my @libpath = map {
q{/libpath:} . Win32::GetShortPathName($_)
} @libpaths;
@sys_cmd = (@cc, $cfile, "${lib}.lib", "/Fe$exefile",
"/link", @libpath
);
} elsif($Config{cc} eq 'CC/DECC') { # VMS
} elsif($Config{cc} =~ /bcc32(\.exe)?/) { # Borland
my @libpath = map { "-L$_" } @libpaths;
@sys_cmd = (@cc, "-o$exefile", "-l$lib", @libpath, $cfile);
} else { # Unix-ish
# gcc, Sun, AIX (gcc, cc)
my @libpath = map { "-L$_" } @libpaths;
@sys_cmd = (@cc, $cfile, "-o", "$exefile", "-l$lib", @libpath);
}
warn "# @sys_cmd\n" if $args{debug};
my $rv = $args{debug} ? system(@sys_cmd) : _quiet_system(@sys_cmd);
push @missing, $lib if $rv != 0 || ! -x $exefile;
_cleanup_exe($exefile);
}
unlink $cfile;
my $miss_string = join( q{, }, map { qq{'$_'} } @missing );
die("Can't link/include $miss_string\n") if @missing;
}
sub _cleanup_exe {
my ($exefile) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/ALBD.pm view on Meta::CPAN
# generates precision and recall values by varying the threshold
# of the A->C ranking measure. Also generates precision at k, and
# mean average precision
# input: none
# output: none, but precision, recall, precision at k, and map values
# output to STDOUT
sub timeSlicing_generatePrecisionAndRecall_implicit {
my $NUM_SAMPLES = 200; #TODO, read fomr file number of samples to average over for timeslicing
my $self = shift;
my $start; #used to record run times
view all matches for this distribution
view release on metacpan or search on metacpan
lib/ALPM.pm view on Meta::CPAN
}
sub search
{
my($self, @qry) = @_;
return map { $_->search(@qry) } $self->dbs;
}
1;
view all matches for this distribution
view release on metacpan or search on metacpan
examples/amfclient.pl view on Meta::CPAN
BEGIN
{
no strict 'refs';
# blessed hash object to JSON object
map
{
my $amf_class = $_;
my $foo = $amf_class."::TO_JSON";
# unbless object
examples/amfclient.pl view on Meta::CPAN
'flex.messaging.messages.AcknowledgeMessage'
);
# blessed hash object to JSON array
map
{
my $foo = $_."::TO_JSON";
# unbless
*$foo = sub {
$_[0]->{'externalizedData'};
view all matches for this distribution
view release on metacpan or search on metacpan
sub getCpuUsage
{
my $output = `uptime`;
my @tokens = split /\s+/, $output;
#Remove commas.
@tokens = map {s/,//g; $_} @tokens;
my @array;
my %hash = ("Name" => 'L 1', "Value" => $tokens[10]);
push @array, \%hash;
my %hash1 = ("Name" => 'L 5', "Value" => $tokens[11]);
view all matches for this distribution
view release on metacpan or search on metacpan
t/manifest.t view on Meta::CPAN
plan skip_all => "Test::CheckManifest 0.9 required" if $@;
open( my $exclude_fh, q{<}, File::Spec->catfile( $dist_dir, 'ignore.txt' ) )
or die "couldn't open ignore.txt: $!";
my @exclude_files = map{
chomp;
/\*/ ?
glob( File::Spec->catfile( $dist_dir, $_ ) ) :
File::Spec->catfile( $dist_dir, $_ )
} ( <$exclude_fh> );
view all matches for this distribution
view release on metacpan or search on metacpan
examples/boxes.pl view on Meta::CPAN
use strict;
use warnings;
use ANSI::Heatmap;
binmode STDOUT, ':utf8';
for my $half (0,1) {
for my $box ([2,2], [3, 5], [9,9], [10,10], [11,11], [21,19]) {
my ($x, $y) = @$box;
my $map = ANSI::Heatmap->new(
half => $half,
min_x => 1,
min_y => 1,
max_x => $x,
max_y => $y,
swatch => 'grayscale',
);
my @white = (
(map { [1,$_], [$x,$_] } (1..$y)),
(map { [$_, 1], [$_, $y] } (1..$x)),
);
for my $c (@white) {
$map->set(@$c, 100);
}
print "$x x $y\n";
print $map, "\n";
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/API/BigBlueButton/Requests.pm view on Meta::CPAN
=cut
sub generate_url_query {
my ( $self, $params ) = @_;
my $string = CORE::join( '&', map { "$_=$params->{$_}" } sort keys %{ $params } );
return $string;
}
sub _generate_data {
view all matches for this distribution
view release on metacpan or search on metacpan
t/00.compile.t view on Meta::CPAN
for my $lib (@module_files)
{
# see L<perlfaq8/How can I capture STDERR from an external command?>
my $stderr = IO::Handle->new;
diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
$^X, @switches, '-e', "require q[$lib]"))
if $ENV{PERL_COMPILE_TEST_DEBUG};
my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]");
binmode $stderr, ':crlf' if $^O eq 'MSWin32';
t/00.compile.t view on Meta::CPAN
close $fh and skip("$file isn't perl", 1) unless $line =~ /^#!\s*(?:\S*perl\S*)((?:\s+-\w*)*)(?:\s*#.*)?$/;
@switches = (@switches, split(' ', $1)) if $1;
my $stderr = IO::Handle->new;
diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
$^X, @switches, '-c', $file))
if $ENV{PERL_COMPILE_TEST_DEBUG};
my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-c', $file);
binmode $stderr, ':crlf' if $^O eq 'MSWin32';
view all matches for this distribution
view release on metacpan or search on metacpan
lib/API/CPanel.pm view on Meta::CPAN
my $params = shift;
return '' unless $params &&
ref $params eq 'HASH' && %$params ;
my $result = join '&', map { "$_=$params->{$_}" } sort keys %$params;
warn $result if $DEBUG;
return $result;
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/API/Client.pm view on Meta::CPAN
=head1 THIN CLIENT
The thin API client library is advantageous as it has complete API coverage and
can easily adapt to changes in the API with minimal effort. As a thin-client
superclass, this module does not map specific HTTP requests to specific
routines, nor does it provide parameter validation, pagination, or other
conventions found in typical API client implementations; Instead, it simply
provides a simple and consistent mechanism for dynamically generating HTTP
requests. Additionally, this module has support for debugging and retrying API
calls as well as throwing exceptions when 4xx and 5xx server response codes are
view all matches for this distribution