Text-Glob-DWIW

 view release on metacpan or  search on metacpan

lib/Text/Glob/DWIW.pm  view on Meta::CPAN

  for (@$opt{qw'unchar unhead backslash'})
     { $_//=''; $_=join'',textglob_expand $_,{default=>1} if /.../&&/^$charclass$/ }
  wantarray ? %$opt : $opt;
}
sub _opt_fmt     # use: my %o=&_opt; => shift/pop;  _opt @_ => don't shift/pop
   { my $opt=&_opt_get//{}; _opt_chk $opt,{qw'paired 0'}; wantarray ? %$opt : $opt }

#~~ import-export                           # v- every 'use' hold a option hash forever
{ sub import   { $INC{'TGDWIW.pm'}=__FILE__ if first {/^:use$/} @_; # use-abbr
                 splice @_,0,1,$pkg if $_[0] eq 'TGDWIW';   my $opt=&_opt_get;
                 my $p=$^H{$keyH}; $^H{$keyH}=my$dk=_uuid;   $_prv{$dk}=$p if $p;
                 $_opt{$dk}=_opt_chk $opt,0,0 if $opt; goto &Exporter::import }
  sub unimport { undef $^H{$keyH} }           # at compile-time: so we can't free any data;
  *TGDWIW::import=\&import; *TGDWIW::unimport=\&unimport; #\ also not called often anyway
}                                                # i: refaddr \%^H is same for same scope
#~~ inner of range
sub _succ ($;$) # wrapping magic++ => # 1a..12g, 1a1..2b2 works (test: {9y-10b})
{ my($val,$to)=@_; $^R=[]; my $carry=1; #use re 'eval';
  return ++$val if $val!~/^(?:([a-z]+[0-9]*|[0-9]+)(?{ [@{$^R},$^N] }))*$/xis; #<< fallback
  my $r=join '',reverse               # ^- no ...|| @{$^R}<=1 optimization,because of carry
    map { my $p=$_;++$p if $carry; $carry=substr $p,0,my$d=length($p)-length; substr$p,$d }



( run in 1.168 second using v1.01-cache-2.11-cpan-49f99fa48dc )