AI-MicroStructure

 view release on metacpan or  search on metacpan

bin/localfiles  view on Meta::CPAN

 compress_ratio => 0.9,
 max_failures => 1,
 max_size => 512 * 1024,
});

 my @result = ();
my $rule;




foreach(@ARGV){
  
    $rule = File::Find::Rule->file->name("*$_*.*")->start("/home/santex/data-hub/stock/" ,"/home/santex/Pictures/1");
            while ( defined ( my $image = $rule->match ) ) {
                 push @result,$image;
          }
print join("\n", @result);
}






__DATA__
my $micro = AI::MicroStructure->new("any");
my $path  = $micro->{state}->{cwd};
my $picdir = sprintf("%s/%s",$ENV{"HOME"},"Pictures/1");
my $pubdir = sprintf("%s/%s",$ENV{"HOME"},"public_html");
push @INC ,-d $path  ? $path : $ENV{"HOME"};
push @INC ,-d  $picdir ? $picdir :"";
push @INC ,-d  $pubdir ? $picdir :"";

my $xx=$memd->get("localfile_".$match);
if(!$xx){
my @images = File::Find::Rule->file()
->name('*'.lc($match).'*\.(png|jpg|gif|svg)')
->in(@INC);
#my $dat = {};
#foreach(@images){
  
  #my @d = split("/",$_);
  
 # $dat->{shift @d} = $_;
#}
#@images = values $dat;#@images[0..500] unless $#images<500;
#$data->{images}=[@images];

#my $cmd = sprintf( "montage '%s' /home/santex/Pictures/montage/".$match."-all.jpg",join("' '",@{$data->{images}}));
#`$cmd`;
 
 
 my @files = File::Find::Rule->file()
->name('*'.ucfirst($match).'*\.(pdf|json|txt|xml)')
->in(@INC);
 # print  join "\n",sort{$a cmp $b}@files;
$data->{files}=[@files];

my $j = encode_json($data);
$memd->set("localfiles_".$match,$j);
print $j;
}else{
$data = decode_json( $xx);
print $xx;


}



( run in 0.943 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )