AI-MicroStructure
view release on metacpan or search on metacpan
lib/AI/MicroStructure.pm view on Meta::CPAN
# names
".$list;
}
sub save_new {
my $self = shift;
my $StructureName = shift;
my $data = shift;
if($StructureName){
#$StructureName = lc $self->trim(`micro`) unless($StructureName);
my $file = "$absstructdir/$StructureName.pm";
print `mkdir -p $absstructdir` unless(-d $absstructdir);
my $fh;
open($fh,">$file") || warn @{[$file,$!]};
print $fh $self->getBlank($StructureName,$data);
close $fh;
$Structure = $StructureName;
push @CWD,$file;
return 1;
}
}
sub drop {
my $self = shift;
my $StructureName = shift;
my @file = grep{/$StructureName.pm/}map{File::Glob::bsd_glob(
File::Spec->catfile( $_, ($structdir,"*.pm") ) )}@CWD;
my $fh = shift @file;
if(`ls $fh`)
{
print `rm $fh`;
}
#push @CWD,$file[1];
return 1;
}
sub help{
}
END{
if($init){}
if($available){}
if($lib){}
if($list){
p @{[__PACKAGE__->getComponents]};
}
if($use){}
if($off){}
if($switch){}
if($mirror){}
if($version){
printf($VERSION);
exit(0);
}
if($help) {
printf(__PACKAGE__->help());
exit(0);
}
if($drop == 1) {
__PACKAGE__->drop($StructureName);
exit 0;
}
if($new==1){
use Term::ReadKey;
use JSON;
my $data = decode_json(lc`micro-sense $StructureName words`);
my $char;
my $line;
my $senses=@{$data->{"senses"}};
$senses= 0 unless($senses);
if(!$verbose){
printf("\n
\033[0;34m
%s
Type: the number you choose 1..$senses
\033[0m",__PACKAGE__->usage($StructureName,$senses,$data));
}
$line = 1 unless($senses != 1);
if($verbose){
$line=1;
}
chomp($line = <STDIN>) unless($line);
my $d = join("#",@{$data->{rows}->{search}});
my @d = grep{/^$line#/}split("sense~~~~~~~~~",$d);
@{$data->{rows}->{"search"}}=split("#",join("",@d));
if($line>0){
__PACKAGE__->save_new($StructureName,$data,$line);
exit 0;
}else{
printf "your logic is today impaired !!!\n";
exit 0;
}
}
if($write == 1) {
__PACKAGE__->save_default();
}
}
sub usage {
my $self = shift;
my $search = shift;
my $senseNr = shift;
my $data = shift;
my $usage = << 'EOT';
.--'"""""--.>_
.-' o\\b.\o._o.`-.
.-'.- ) \d888888888888b.
/.' b Y8888888888888888b.
.-'. 8888888888888888888888888b
/ o888 Y Y8888888888888888888888b
/ d888P/ /| Y"Y8888888888888888888b
J d8888/| Y .o._. "Y8888888888888Y" \
|d Y888b|obd88888bo. """Y88888Y' .od8
Fdd 8888888888888888888bo._'|| d88888|
Fd d 88\ Y8888Y "Y888888888b, d888888P
d-b 8888b Y88P' """""Y888b8888P"|
J 8\88888888P `m. """"" |
|| `8888888P' "Ymm._ _J
|\\ Y8888P ' .mmm.YM) .mMF"'
| \\ Y888J ' < (@)>.- ` /MFm. |
J \ `YY ""' :: MM @)>F
L /) 88 : | ""\|
| ( ( Yb . ' . | L
\ bo 8b . . J | <0>_
\ "' . . . . L F <1>_
o._.:. . . \mm,__J/ / <2>_
( run in 2.368 seconds using v1.01-cache-2.11-cpan-cdf2f3d4e48 )