Aion-Fs
view release on metacpan or search on metacpan
path +{ ext => joinext qw/x y z/ } # => .x.y.z
```
## include (;$pkg)
ÐодклÑÑÐ°ÐµÑ `$pkg` (еÑли он еÑÑ Ð½Ðµ бÑл подклÑÑÑн ÑеÑез `use` или `require`) и возвÑаÑÐ°ÐµÑ ÐµÐ³Ð¾. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
Файл lib/A.pm:
```perl
package A;
sub new { bless {@_}, shift }
1;
```
Файл lib/N.pm:
```perl
package N;
sub ex { 123 }
1;
```
lib/Aion/Fs.md view on Meta::CPAN
path +{ ext => joinext qw/x y z/ } # => .x.y.z
```
## include (;$pkg)
ÐодклÑÑÐ°ÐµÑ `$pkg` (еÑли он еÑÑ Ð½Ðµ бÑл подклÑÑÑн ÑеÑез `use` или `require`) и возвÑаÑÐ°ÐµÑ ÐµÐ³Ð¾. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
Файл lib/A.pm:
```perl
package A;
sub new { bless {@_}, shift }
1;
```
Файл lib/N.pm:
```perl
package N;
sub ex { 123 }
1;
```
lib/Aion/Fs.pm view on Meta::CPAN
my $files = @_? shift: $_;
$files = [$files] unless ref $files;
my @noenters; my $errorenter = sub {};
my $ex = @_ && ref($_[$#_]) eq 'Aion::Fs::Find'
? pop
: undef;
if($ex) {
bless $ex, 'Aion::Fs';
if(Scalar::Util::reftype $ex eq 'CODE') {
$errorenter = $ex;
} else {
$errorenter = bless pop @$ex, undef if Scalar::Util::reftype($ex->[$#$ex]) eq "CODE";
push @noenters, _filters @$ex;
}
}
my @filters = _filters @_;
my $iter = Aion::Fs::Find->new(
noenters => \@noenters,
errorenter => $errorenter,
filters => \@filters,
files => $files,
);
defined(wantarray)
? (wantarray? @$iter: $iter)
: do { while(defined $iter->next) {} };
}
# Ðе вÑ
одиÑÑ Ð² подкаÑалоги
sub noenter(@) {
bless [@_], "Aion::Fs::Find"
}
# ÐÑзÑваеÑÑÑ Ð´Ð»Ñ Ð²ÑеÑ
оÑибок ввода-вÑвода
sub errorenter(&) {
bless shift, "Aion::Fs::Find"
}
# ÐÑÑÐ°Ð½Ð°Ð²Ð»Ð¸Ð²Ð°ÐµÑ find бÑдÑÑи вÑзван Ñ Ð¾Ð´Ð½Ð¾Ð³Ð¾ из его ÑилÑÑÑов, errorenter или noenter
sub find_stop() {
die bless \(my $stop = 1), "Aion::Fs::Find"
}
# ÐÑÐ¾Ð¸Ð·Ð²Ð¾Ð´Ð¸Ñ Ð·Ð°Ð¼ÐµÐ½Ñ Ð²Ð¾ вÑеÑ
ÑказаннÑÑ
ÑайлаÑ
. ÐозвÑаÑÐ°ÐµÑ ÑÐ°Ð¹Ð»Ñ Ð² коÑоÑÑÑ
замен не бÑло
sub replace(&@) {
my $fn = shift;
my @noreplace; local $_; my $pkg = caller;
my $aref = "$pkg\::a"; my $bref = "$pkg\::b";
for $$aref (@_) {
if(ref $$aref) { ($$aref, $$bref) = @$$aref } else { $$bref = ":utf8" }
my $file = $_ = cat [$$aref, $$bref];
lib/Aion/Fs.pm view on Meta::CPAN
path +{ ext => joinext qw/x y z/ } # => .x.y.z
=head2 include (;$pkg)
Connects C<$pkg> (if it has not already been connected via C<use> or C<require>) and returns it. Without a parameter, uses C<$_>.
lib/A.pm file:
package A;
sub new { bless {@_}, shift }
1;
lib/N.pm file:
package N;
sub ex { 123 }
1;
lib/Aion/Fs/Cat.pm view on Meta::CPAN
'&{}' => sub {
my ($self) = @_;
sub { scalar $self->next }
},
'@{}' => sub { [shift->next] },
'""' => sub { "cat<${\shift->{path}}>" },
;
sub new {
my $cls = shift;
bless {@_}, ref $cls || $cls
}
sub path { shift->{path} }
sub next {
my $f = shift->{f};
<$f>
}
sub DESTROY {
lib/Aion/Fs/Find.pm view on Meta::CPAN
'@{}' => sub {
my ($self) = @_;
my @paths; my $path;
push @paths, $path while defined($path = $self->next);
\@paths
},
;
sub new {
my $cls = shift;
bless {@_}, ref $cls || $cls
}
sub next {
my ($self) = @_;
my $path = eval {
my $files = $self->{files};
FILE: while(@$files) {
my $path = shift @$files;
if(-d $path) {
lib/Aion/Fs/Lay.pm view on Meta::CPAN
use common::sense;
use overload fallback => 1,
'*{}' => sub { shift->{f} },
'-X' => \&_fileop,
'""' => sub { "lay<${\shift->{path}}>" },
;
sub new {
my $cls = shift;
bless {@_}, ref $cls || $cls
}
sub path { shift->{path} }
sub DESTROY {
my ($self) = @_;
close $self->{f};
}
t/aion/fs.t view on Meta::CPAN
local ($::_g0 = do {path +{ ext => joinext qw/x y z/ }}, $::_e0 = ".x.y.z"); ::ok $::_g0 eq $::_e0, 'path +{ ext => joinext qw/x y z/ } # => .x.y.z' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# ## include (;$pkg)
#
# ÐодклÑÑÐ°ÐµÑ `$pkg` (еÑли он еÑÑ Ð½Ðµ бÑл подклÑÑÑн ÑеÑез `use` или `require`) и возвÑаÑÐ°ÐµÑ ÐµÐ³Ð¾. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
#
# Файл lib/A.pm:
#@> lib/A.pm
#>> package A;
#>> sub new { bless {@_}, shift }
#>> 1;
#@< EOF
#
# Файл lib/N.pm:
#@> lib/N.pm
#>> package N;
#>> sub ex { 123 }
#>> 1;
#@< EOF
#
( run in 2.718 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )