view release on metacpan or search on metacpan
```perl
use Aion::Fs;
lay mkpath "hello/world.txt", "hi!";
lay mkpath "hello/moon.txt", "noreplace";
lay mkpath "hello/big/world.txt", "hellow!";
lay mkpath "hello/small/world.txt", "noenter";
mtime "hello"; # ~> ^\d+(\.\d+)?$
[map cat, grep -f, find ["hello/big", "hello/small"]]; # --> [qw/ hellow! noenter /]
my @noreplaced = replace { s/h/$a $b H/ }
find "hello", "-f", "*.txt", qr/\.txt$/, sub { /\.txt$/ },
noenter "*small*",
errorenter { warn "find $_: $!" };
\@noreplaced; # --> ["hello/moon.txt"]
cat "hello/world.txt"; # => hello/world.txt :utf8 Hi!
cat "hello/moon.txt"; # => noreplace
my $count = 0;
find "ex", sub { find_stop if ++$count == 3; 1};
$count # -> 3
```
### See also
* [AudioFile::Find](https://metacpan.org/pod/AudioFile::Find) â иÑÐµÑ Ð°ÑдиоÑÐ°Ð¹Ð»Ñ Ð² Ñказанной диÑекÑоÑии. ÐозволÑÐµÑ ÑилÑÑÑоваÑÑ Ð¸Ñ
по аÑÑибÑÑам: названиÑ, аÑÑиÑÑÑ, жа...
* [Directory::Iterator](https://metacpan.org/pod/Directory::Iterator) â `$it = Directory::Iterator->new($dir, %opts); push @paths, $_ while <$it>`.
* [IO::All](https://metacpan.org/pod/IO::All) â `@paths = map { "$_" } grep { -f $_ && $_->size > 10*1024 } io(".")->all(0)`.
* [IO::All::Rule](https://metacpan.org/pod/IO::All::Rule) â `$next = IO::All::Rule->new->file->size(">10k")->iter($dir1, $dir2); push @paths, "$f" while $f = $next->()`.
* [File::Find](https://metacpan.org/pod/File::Find) â `find( sub { push @paths, $File::Find::name if /\.png/ }, $dir )`.
* [File::Find::utf8](https://metacpan.org/pod/File::Find::utf8) â как [File::Find](https://metacpan.org/pod/File::Find), ÑолÑко пÑÑи Ñайлов в _utf8_.
* [File::Find::Age](https://metacpan.org/pod/File::Find::Age) â ÑоÑÑиÑÑÐµÑ ÑÐ°Ð¹Ð»Ñ Ð¿Ð¾ вÑемени модиÑикаÑии (наÑледÑÐµÑ [File::Find::Rule](https://metacpan.org/pod/File::Find::Rule)): `File::Find::Age->in($dir1,...
* [File::Find::Declare](https://metacpan.org/pod/File::Find::Declare) â `@paths = File::Find::Declare->new({ size => '>10K', perms => 'wr-wr-wr-', modified => '<2010-01-30', recurse => 1, dirs => [$dir1] })->find`.
* [File::Find::Iterator](https://metacpan.org/pod/File::Find::Iterator) â Ð¸Ð¼ÐµÐµÑ ÐÐРинÑеÑÑÐµÐ¹Ñ Ñ Ð¸ÑеÑаÑоÑом и ÑÑнкÑии `imap` и `igrep`.
* [File::Find::Match](https://metacpan.org/pod/File::Find::Match) â вÑзÑÐ²Ð°ÐµÑ Ð¾Ð±ÑабоÑÑик на каждÑй подоÑедÑий ÑилÑÑÑ. ÐоÑ
ож на `switch`.
* [File::Find::Node](https://metacpan.org/pod/File::Find::Node) â обÑ
Ð¾Ð´Ð¸Ñ Ð¸ÐµÑаÑÑ
Ð¸Ñ Ñайлов паÑаллелÑно неÑколÑкими пÑоÑеÑÑами: `tie @paths, IPC::Shareable, { key => "GLUE STRING", create => 1 }; F...
* [File::Find::Fast](https://metacpan.org/pod/File::Find::Fast) â `@paths = @{ find($dir) }`.
* [File::Find::Object](https://metacpan.org/pod/File::Find::Object) â Ð¸Ð¼ÐµÐµÑ ÐÐРинÑеÑÑÐµÐ¹Ñ Ñ Ð¸ÑеÑаÑоÑом.
* [File::Find::Parallel](https://metacpan.org/pod/File::Find::Parallel) â ÑÐ¼ÐµÐµÑ ÑÑавниваÑÑ Ð´Ð²Ð° каÑалога и возвÑаÑаÑÑ Ð¸Ñ
обÑединение, пеÑеÑеÑение и колиÑеÑÑвенное пеÑеÑ...
* [File::Find::Random](https://metacpan.org/pod/File::Find::Random) â вÑбиÑÐ°ÐµÑ Ñайл или диÑекÑоÑÐ¸Ñ Ð½Ð°Ñгад из иеÑаÑÑ
ии Ñайлов.
* [File::Find::Rex](https://metacpan.org/pod/File::Find::Rex) â `@paths = File::Find::Rex->new(recursive => 1, ignore_hidden => 1)->query($dir, qr/^b/i)`.
* [File::Find::Rule](https://metacpan.org/pod/File::Find::Rule) â `@files = File::Find::Rule->any( File::Find::Rule->file->name('*.mp3', '*.ogg')->size('>2M'), File::Find::Rule->empty )->in($dir1, $dir2);`. ÐÐ¼ÐµÐµÑ Ð¸ÑеÑаÑоÑ, пÑоÑед...
* [File::Find::Wanted](https://metacpan.org/pod/File::Find::Wanted) â `@paths = find_wanted( sub { -f && /\.png/ }, $dir )`.
* [File::Hotfolder](https://metacpan.org/pod/File::Hotfolder) â `watch( $dir, callback => sub { push @paths, shift } )->loop`. РабоÑÐ°ÐµÑ Ð½Ð° `AnyEvent`. ÐаÑÑÑаиваемÑй. ÐÑÑÑ ÑаÑпаÑаллеливание на неÑко...
* [File::Mirror](https://metacpan.org/pod/File::Mirror) â ÑоÑмиÑÑÐµÑ Ñак же паÑаллелÑнÑй пÑÑÑ Ð´Ð»Ñ ÐºÐ¾Ð¿Ð¸ÑÐ¾Ð²Ð°Ð½Ð¸Ñ Ñайлов: `recursive { my ($src, $dst) = @_; push @paths, $src } '/path/A', '/path/B'`.
* [File::Set](https://metacpan.org/pod/File::Set) â `$fs = File::Set->new; $fs->add($dir); @paths = map { $_->[0] } $fs->get_path_list`.
* [File::Wildcard](https://metacpan.org/pod/File::Wildcard) â `$fw = File::Wildcard->new(exclude => qr/.svn/, case_insensitive => 1, sort => 1, path => "src///*.cpp", match => qr(^src/(.*?)\.cpp$), derive => ['src/$1.o','src/$1.hpp']); push @paths,...
* [File::Wildcard::Find](https://metacpan.org/pod/File::Wildcard::Find) â `findbegin($dir); push @paths, $f while $f = findnext()` или `findbegin($dir); @paths = findall()`.
* [File::Util](https://metacpan.org/pod/File::Util) â `File::Util->new->list_dir($dir, qw/ --pattern=\.txt$ --files-only --recurse /)`.
* [Mojo::File](https://metacpan.org/pod/Mojo::File) â `say for path($path)->list_tree({hidden => 1, dir => 1})->each`.
* [Path::Find](https://metacpan.org/pod/Path::Find) â `@paths = path_find( $dir, "*.png" )`. ÐÐ»Ñ ÑложнÑÑ
запÑоÑов иÑполÑзÑÐµÑ _matchable_: `my $sub = matchable( sub { my( $entry, $directory, $fullname, $depth ) = @_; $dep...
* [Path::Extended::Dir](https://metacpan.org/pod/Path::Extended::Dir) â `@paths = Path::Extended::Dir->new($dir)->find('*.txt')`.
* [Path::Iterator::Rule](https://metacpan.org/pod/Path::Iterator::Rule) â `$i = Path::Iterator::Rule->new->file; @paths = $i->clone->size(">10k")->all(@dirs); $i->size("<10k")...`.
* [Path::Class::Each](https://metacpan.org/pod/Path::Class::Each) â `dir($dir)->each(sub { push @paths, "$_" })`.
* [Path::Class::Iterator](https://metacpan.org/pod/Path::Class::Iterator) â `$i = Path::Class::Iterator->new(root => $dir, depth => 2); until ($i->done) { push @paths, $i->next->stringify }`.
* [Path::Class::Rule](https://metacpan.org/pod/Path::Class::Rule) â `@paths = Path::Class::Rule->new->file->size(">10k")->all($dir)`.
Файл lib/N.pm:
```perl
package N;
sub ex { 123 }
1;
```
```perl
use lib "lib";
include("A")->new # ~> A=HASH\(0x\w+\)
[map include, qw/A N/] # --> [qw/A N/]
{ local $_="N"; include->ex } # -> 123
```
## catonce (;$file)
СÑиÑÑÐ²Ð°ÐµÑ Ñайл в пеÑвÑй Ñаз. ÐÑÐ±Ð°Ñ Ð¿Ð¾ÑледÑÑÑÐ°Ñ Ð¿Ð¾Ð¿ÑÑка ÑÑиÑаÑÑ ÑÑÐ¾Ñ Ñайл возвÑаÑÐ°ÐµÑ `undef`. ÐÑполÑзÑеÑÑÑ Ð´Ð»Ñ Ð²ÑÑавки модÑлей js и css в ÑезÑлÑ...
* `$file` Ð¼Ð¾Ð¶ÐµÑ ÑодеÑжаÑÑ Ð¼Ð°ÑÑÐ¸Ð²Ñ Ð¸Ð· двÑÑ
ÑлеменÑов. ÐеÑвÑй ÑаÑÑмаÑÑиваеÑÑÑ ÐºÐ°Ðº пÑÑÑ, а вÑоÑой â как Ñлой. Слой по ÑмолÑÐ°Ð½Ð¸Ñ â `:utf8`.
* ÐÑли `$file` не Ñказан â иÑполÑзÑÐµÑ `$_`.
eval { goto_editor "`", 1 }; $@ # ~> `:1 --> 512
```
## from_pkg (;$pkg)
ÐеÑÐµÐ²Ð¾Ð´Ð¸Ñ Ð¿Ð°ÐºÐµÑ Ð² пÑÑÑ Ð¤Ð¡. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
```perl
from_pkg "Aion::Fs" # => Aion/Fs.pm
[map from_pkg, "Aion::Fs", "A::B::C"] # --> ["Aion/Fs.pm", "A/B/C.pm"]
```
## to_pkg (;$path)
ÐеÑÐµÐ²Ð¾Ð´Ð¸Ñ Ð¿ÑÑÑ Ð¸Ð· ФС в пакеÑ. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
```perl
to_pkg "Aion/Fs.pm" # => Aion::Fs
[map to_pkg, "Aion/Fs.md", "A/B/C.md"] # --> ["Aion::Fs", "A::B::C"]
```
## from_inc (;$pkg)
ÐеÑÐµÐ²Ð¾Ð´Ð¸Ñ Ð¿Ð°ÐºÐµÑ Ð² пÑÑÑ Ð¤Ð¡ в `@INC`. Файл Ñ Ð¿Ð°ÐºÐµÑом должен ÑÑÑеÑÑвоваÑÑ Ð² одном из пÑÑей `@INC`. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
```perl
from_inc "Aion::Fs" # -> $INC{'Aion/Fs.pm'}
[map from_inc, "A::B::C", "Aion::Fs"] # --> [$INC{'Aion/Fs.pm'}]
from_inc "A::B::C" # -> undef
```
## to_inc (;$path)
ÐеÑÐµÐ²Ð¾Ð´Ð¸Ñ Ð¿ÑÑÑ Ð¸Ð· ФС в `@INC` в пакеÑ. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
```perl
to_inc $INC{'Aion/Fs.pm'} # => Aion::Fs
[map to_inc,"A/B/C.pm", $INC{'Aion/Fs.pm'}] # --> ["Aion::Fs"]
to_inc 'Aion/Fs.pm' # -> undef
```
## ilay (;$path)
СоздаÑÑ ÑайловÑй деÑкÑипÑоÑ. Ðн ÑÐ¼ÐµÐµÑ Ð·Ð°ÐºÑÑваÑÑÑÑ, как ÑолÑко на него иÑÑÐµÐ·Ð½ÐµÑ Ð¿Ð¾ÑледнÑÑ ÑÑÑлка.
Так же Ð¸Ð¼ÐµÐµÑ Ð¼ÐµÑод `path`, к-й возвÑаÑÐ°ÐµÑ Ð¿ÑÑÑ Ðº ÑайлÑ.
i18n/Aion/Fs.ru-en.po view on Meta::CPAN
msgid "Ð ÑÑом пÑимеÑе `find` не Ð¼Ð¾Ð¶ÐµÑ Ð²Ð¾Ð¹Ñи в подкаÑалог и пеÑедаÑÑ Ð¾ÑÐ¸Ð±ÐºÑ Ð² ÑÑнкÑÐ¸Ñ `errorenter` (Ñм. ниже) Ñ ÑÑÑановленнÑми пеÑеменнÑми `$_` и `$!` (пÑÑÑ...
msgstr "In this example, `find` cannot enter the subdirectory and passes an error to the `errorenter` function (see below) with the `$_` and `$!` variables set (to the directory path and the OS error message)."
msgid "**Ðнимание!** ÐÑли `errorenter` не Ñказана, Ñо вÑе оÑибки **игноÑиÑÑÑÑÑÑ**!"
msgstr "**Attention!** If `errorenter` is not specified, then all errors are **ignored**!"
msgid ""
"* [AudioFile::Find](https://metacpan.org/pod/AudioFile::Find) â иÑÐµÑ Ð°ÑдиоÑÐ°Ð¹Ð»Ñ Ð² Ñказанной диÑекÑоÑии. ÐозволÑÐµÑ ÑилÑÑÑоваÑÑ Ð¸Ñ
по аÑÑибÑÑам: названиÑ, аÑÑиÑÑÑ, жÐ...
"* [Directory::Iterator](https://metacpan.org/pod/Directory::Iterator) â `$it = Directory::Iterator->new($dir, %opts); push @paths, $_ while <$it>`.\n"
"* [IO::All](https://metacpan.org/pod/IO::All) â `@paths = map { \"$_\" } grep { -f $_ && $_->size > 10*1024 } io(\".\")->all(0)`.\n"
"* [IO::All::Rule](https://metacpan.org/pod/IO::All::Rule) â `$next = IO::All::Rule->new->file->size(\">10k\")->iter($dir1, $dir2); push @paths, \"$f\" while $f = $next->()`.\n"
"* [File::Find](https://metacpan.org/pod/File::Find) â `find( sub { push @paths, $File::Find::name if /\\.png/ }, $dir )`.\n"
"* [File::Find::utf8](https://metacpan.org/pod/File::Find::utf8) â как [File::Find](https://metacpan.org/pod/File::Find), ÑолÑко пÑÑи Ñайлов в _utf8_.\n"
"* [File::Find::Age](https://metacpan.org/pod/File::Find::Age) â ÑоÑÑиÑÑÐµÑ ÑÐ°Ð¹Ð»Ñ Ð¿Ð¾ вÑемени модиÑикаÑии (наÑледÑÐµÑ [File::Find::Rule](https://metacpan.org/pod/File::Find::Rule)): `File::Find::Age->in($dir1...
"* [File::Find::Declare](https://metacpan.org/pod/File::Find::Declare) â `@paths = File::Find::Declare->new({ size => '>10K', perms => 'wr-wr-wr-', modified => '<2010-01-30', recurse => 1, dirs => [$dir1] })->find`.\n"
"* [File::Find::Iterator](https://metacpan.org/pod/File::Find::Iterator) â Ð¸Ð¼ÐµÐµÑ ÐÐРинÑеÑÑÐµÐ¹Ñ Ñ Ð¸ÑеÑаÑоÑом и ÑÑнкÑии `imap` и `igrep`.\n"
"* [File::Find::Match](https://metacpan.org/pod/File::Find::Match) â вÑзÑÐ²Ð°ÐµÑ Ð¾Ð±ÑабоÑÑик на каждÑй подоÑедÑий ÑилÑÑÑ. ÐоÑ
ож на `switch`.\n"
"* [File::Find::Node](https://metacpan.org/pod/File::Find::Node) â обÑ
Ð¾Ð´Ð¸Ñ Ð¸ÐµÑаÑÑ
Ð¸Ñ Ñайлов паÑаллелÑно неÑколÑкими пÑоÑеÑÑами: `tie @paths, IPC::Shareable, { key => \"GLUE STRING\", create => 1 }...
"* [File::Find::Fast](https://metacpan.org/pod/File::Find::Fast) â `@paths = @{ find($dir) }`.\n"
"* [File::Find::Object](https://metacpan.org/pod/File::Find::Object) â Ð¸Ð¼ÐµÐµÑ ÐÐРинÑеÑÑÐµÐ¹Ñ Ñ Ð¸ÑеÑаÑоÑом.\n"
"* [File::Find::Parallel](https://metacpan.org/pod/File::Find::Parallel) â ÑÐ¼ÐµÐµÑ ÑÑавниваÑÑ Ð´Ð²Ð° каÑалога и возвÑаÑаÑÑ Ð¸Ñ
обÑединение, пеÑеÑеÑение и колиÑеÑÑвенное пеÑеÑ...
"* [File::Find::Random](https://metacpan.org/pod/File::Find::Random) â вÑбиÑÐ°ÐµÑ Ñайл или диÑекÑоÑÐ¸Ñ Ð½Ð°Ñгад из иеÑаÑÑ
ии Ñайлов.\n"
"* [File::Find::Rex](https://metacpan.org/pod/File::Find::Rex) â `@paths = File::Find::Rex->new(recursive => 1, ignore_hidden => 1)->query($dir, qr/^b/i)`.\n"
"* [File::Find::Rule](https://metacpan.org/pod/File::Find::Rule) â `@files = File::Find::Rule->any( File::Find::Rule->file->name('*.mp3', '*.ogg')->size('>2M'), File::Find::Rule->empty )->in($dir1, $dir2);`. ÐÐ¼ÐµÐµÑ Ð¸ÑеÑаÑоÑ, пÑоÑеÐ...
"* [File::Find::Wanted](https://metacpan.org/pod/File::Find::Wanted) â `@paths = find_wanted( sub { -f && /\\.png/ }, $dir )`.\n"
"* [File::Hotfolder](https://metacpan.org/pod/File::Hotfolder) â `watch( $dir, callback => sub { push @paths, shift } )->loop`. РабоÑÐ°ÐµÑ Ð½Ð° `AnyEvent`. ÐаÑÑÑаиваемÑй. ÐÑÑÑ ÑаÑпаÑаллеливание на неÑкÐ...
"* [File::Mirror](https://metacpan.org/pod/File::Mirror) â ÑоÑмиÑÑÐµÑ Ñак же паÑаллелÑнÑй пÑÑÑ Ð´Ð»Ñ ÐºÐ¾Ð¿Ð¸ÑÐ¾Ð²Ð°Ð½Ð¸Ñ Ñайлов: `recursive { my ($src, $dst) = @_; push @paths, $src } '/path/A', '/path/B'`.\n"
"* [File::Set](https://metacpan.org/pod/File::Set) â `$fs = File::Set->new; $fs->add($dir); @paths = map { $_->[0] } $fs->get_path_list`.\n"
"* [File::Wildcard](https://metacpan.org/pod/File::Wildcard) â `$fw = File::Wildcard->new(exclude => qr/.svn/, case_insensitive => 1, sort => 1, path => \"src///*.cpp\", match => qr(^src/(.*?)\\.cpp$), derive => ['src/$1.o','src/$1.hpp']); push @pa...
"* [File::Wildcard::Find](https://metacpan.org/pod/File::Wildcard::Find) â `findbegin($dir); push @paths, $f while $f = findnext()` или `findbegin($dir); @paths = findall()`.\n"
"* [File::Util](https://metacpan.org/pod/File::Util) â `File::Util->new->list_dir($dir, qw/ --pattern=\\.txt$ --files-only --recurse /)`.\n"
"* [Mojo::File](https://metacpan.org/pod/Mojo::File) â `say for path($path)->list_tree({hidden => 1, dir => 1})->each`.\n"
"* [Path::Find](https://metacpan.org/pod/Path::Find) â `@paths = path_find( $dir, \"*.png\" )`. ÐÐ»Ñ ÑложнÑÑ
запÑоÑов иÑполÑзÑÐµÑ _matchable_: `my $sub = matchable( sub { my( $entry, $directory, $fullname, $depth ) = @_; $...
"* [Path::Extended::Dir](https://metacpan.org/pod/Path::Extended::Dir) â `@paths = Path::Extended::Dir->new($dir)->find('*.txt')`.\n"
"* [Path::Iterator::Rule](https://metacpan.org/pod/Path::Iterator::Rule) â `$i = Path::Iterator::Rule->new->file; @paths = $i->clone->size(\">10k\")->all(@dirs); $i->size(\"<10k\")...`.\n"
"* [Path::Class::Each](https://metacpan.org/pod/Path::Class::Each) â `dir($dir)->each(sub { push @paths, \"$_\" })`.\n"
"* [Path::Class::Iterator](https://metacpan.org/pod/Path::Class::Iterator) â `$i = Path::Class::Iterator->new(root => $dir, depth => 2); until ($i->done) { push @paths, $i->next->stringify }`.\n"
"* [Path::Class::Rule](https://metacpan.org/pod/Path::Class::Rule) â `@paths = Path::Class::Rule->new->file->size(\">10k\")->all($dir)`."
msgstr ""
"* [AudioFile::Find](https://metacpan.org/pod/AudioFile::Find) â searches for audio files in the specified directory. Allows you to filter them by attributes: title, artist, genre, album and track.\n"
"* [Directory::Iterator](https://metacpan.org/pod/Directory::Iterator) â `$it = Directory::Iterator->new($dir, %opts); push @paths, $_ while <$it>`.\n"
"* [IO::All](https://metacpan.org/pod/IO::All) â `@paths = map { \"$_\" } grep { -f $_ && $_->size > 10*1024 } io(\".\")->all(0)`.\n"
"* [IO::All::Rule](https://metacpan.org/pod/IO::All::Rule) â `$next = IO::All::Rule->new->file->size(\">10k\")->iter($dir1, $dir2); push @paths, \"$f\" while $f = $next->()`.\n"
"* [File::Find](https://metacpan.org/pod/File::Find) â `find( sub { push @paths, $File::Find::name if /\\.png/ }, $dir )`.\n"
"* [File::Find::utf8](https://metacpan.org/pod/File::Find::utf8) â like [File::Find](https://metacpan.org/pod/File::Find), only file paths are in _utf8_.\n"
"* [File::Find::Age](https://metacpan.org/pod/File::Find::Age) â sorts files by modification time (inherits [File::Find::Rule](https://metacpan.org/pod/File::Find::Rule)): `File::Find::Age->in($dir1, $dir2)`.\n"
"* [File::Find::Declare](https://metacpan.org/pod/File::Find::Declare) â `@paths = File::Find::Declare->new({ size => '>10K', perms => 'wr-wr-wr-', modified => '<2010-01-30', recurse => 1, dirs => [$dir1] })->find`.\n"
"* [File::Find::Iterator](https://metacpan.org/pod/File::Find::Iterator) â has an OOP interface with an iterator and the `imap` and `igrep` functions.\n"
"* [File::Find::Match](https://metacpan.org/pod/File::Find::Match) â calls a handler for each matching filter. Similar to `switch`.\n"
"* [File::Find::Node](https://metacpan.org/pod/File::Find::Node) â traverses the file hierarchy in parallel by several processes: `tie @paths, IPC::Shareable, { key => \"GLUE STRING\", create => 1 }; File::Find::Node->new(\".\")->process(sub { my $...
"* [File::Find::Fast](https://metacpan.org/pod/File::Find::Fast) â `@paths = @{ find($dir) }`.\n"
"* [File::Find::Object](https://metacpan.org/pod/File::Find::Object) â has an OOP interface with an iterator.\n"
"* [File::Find::Parallel](https://metacpan.org/pod/File::Find::Parallel) â can compare two directories and return their union, intersection and quantitative intersection.\n"
"* [File::Find::Random](https://metacpan.org/pod/File::Find::Random) â selects a file or directory at random from the file hierarchy.\n"
"* [File::Find::Rex](https://metacpan.org/pod/File::Find::Rex) â `@paths = File::Find::Rex->new(recursive => 1, ignore_hidden => 1)->query($dir, qr/^b/i)`.\n"
"* [File::Find::Rule](https://metacpan.org/pod/File::Find::Rule) â `@files = File::Find::Rule->any( File::Find::Rule->file->name('*.mp3', '*.ogg')->size('>2M'), File::Find::Rule->empty )->in($dir1, $dir2);`. Has an iterator, procedural interface an...
"* [File::Find::Wanted](https://metacpan.org/pod/File::Find::Wanted) â `@paths = find_wanted( sub { -f && /\\.png/ }, $dir )`.\n"
"* [File::Hotfolder](https://metacpan.org/pod/File::Hotfolder) â `watch( $dir, callback => sub { push @paths, shift } )->loop`. Powered by `AnyEvent`. Customizable. There is parallelization into several processes.\n"
"* [File::Mirror](https://metacpan.org/pod/File::Mirror) â also forms a parallel path for copying files: `recursive { my ($src, $dst) = @_; push @paths, $src } '/path/A', '/path/B'`.\n"
"* [File::Set](https://metacpan.org/pod/File::Set) â `$fs = File::Set->new; $fs->add($dir); @paths = map { $_->[0] } $fs->get_path_list`.\n"
"* [File::Wildcard](https://metacpan.org/pod/File::Wildcard) â `$fw = File::Wildcard->new(exclude => qr/.svn/, case_insensitive => 1, sort => 1, path => \"src///*.cpp\", match => qr(^src/(.*?)\\.cpp$), derive => ['src/$1.o','src/$1.hpp']); push @pa...
"* [File::Wildcard::Find](https://metacpan.org/pod/File::Wildcard::Find) â `findbegin($dir); push @paths, $f while $f = findnext()` or `findbegin($dir); @paths = findall()`.\n"
"* [File::Util](https://metacpan.org/pod/File::Util) â `File::Util->new->list_dir($dir, qw/ --pattern=\\.txt$ --files-only --recurse /)`.\n"
"* [Mojo::File](https://metacpan.org/pod/Mojo::File) â `say for path($path)->list_tree({hidden => 1, dir => 1})->each`.\n"
"* [Path::Find](https://metacpan.org/pod/Path::Find) â `@paths = path_find( $dir, \"*.png\" )`. For complex queries, use _matchable_: `my $sub = matchable( sub { my( $entry, $directory, $fullname, $depth ) = @_; $depth <= 3 }`.\n"
"* [Path::Extended::Dir](https://metacpan.org/pod/Path::Extended::Dir) â `@paths = Path::Extended::Dir->new($dir)->find('*.txt')`.\n"
"* [Path::Iterator::Rule](https://metacpan.org/pod/Path::Iterator::Rule) â `$i = Path::Iterator::Rule->new->file; @paths = $i->clone->size(\">10k\")->all(@dirs); $i->size(\"<10k\")...`.\n"
"* [Path::Class::Each](https://metacpan.org/pod/Path::Class::Each) â `dir($dir)->each(sub { push @paths, \"$_\" })`.\n"
"* [Path::Class::Iterator](https://metacpan.org/pod/Path::Class::Iterator) â `$i = Path::Class::Iterator->new(root => $dir, depth => 2); until ($i->done) { push @paths, $i->next->stringify }`.\n"
"* [Path::Class::Rule](https://metacpan.org/pod/Path::Class::Rule) â `@paths = Path::Class::Rule->new->file->size(\">10k\")->all($dir)`."
lib/Aion/Fs.md view on Meta::CPAN
```perl
use Aion::Fs;
lay mkpath "hello/world.txt", "hi!";
lay mkpath "hello/moon.txt", "noreplace";
lay mkpath "hello/big/world.txt", "hellow!";
lay mkpath "hello/small/world.txt", "noenter";
mtime "hello"; # ~> ^\d+(\.\d+)?$
[map cat, grep -f, find ["hello/big", "hello/small"]]; # --> [qw/ hellow! noenter /]
my @noreplaced = replace { s/h/$a $b H/ }
find "hello", "-f", "*.txt", qr/\.txt$/, sub { /\.txt$/ },
noenter "*small*",
errorenter { warn "find $_: $!" };
\@noreplaced; # --> ["hello/moon.txt"]
cat "hello/world.txt"; # => hello/world.txt :utf8 Hi!
cat "hello/moon.txt"; # => noreplace
lib/Aion/Fs.md view on Meta::CPAN
my $count = 0;
find "ex", sub { find_stop if ++$count == 3; 1};
$count # -> 3
```
### See also
* [AudioFile::Find](https://metacpan.org/pod/AudioFile::Find) â иÑÐµÑ Ð°ÑдиоÑÐ°Ð¹Ð»Ñ Ð² Ñказанной диÑекÑоÑии. ÐозволÑÐµÑ ÑилÑÑÑоваÑÑ Ð¸Ñ
по аÑÑибÑÑам: названиÑ, аÑÑиÑÑÑ, жа...
* [Directory::Iterator](https://metacpan.org/pod/Directory::Iterator) â `$it = Directory::Iterator->new($dir, %opts); push @paths, $_ while <$it>`.
* [IO::All](https://metacpan.org/pod/IO::All) â `@paths = map { "$_" } grep { -f $_ && $_->size > 10*1024 } io(".")->all(0)`.
* [IO::All::Rule](https://metacpan.org/pod/IO::All::Rule) â `$next = IO::All::Rule->new->file->size(">10k")->iter($dir1, $dir2); push @paths, "$f" while $f = $next->()`.
* [File::Find](https://metacpan.org/pod/File::Find) â `find( sub { push @paths, $File::Find::name if /\.png/ }, $dir )`.
* [File::Find::utf8](https://metacpan.org/pod/File::Find::utf8) â как [File::Find](https://metacpan.org/pod/File::Find), ÑолÑко пÑÑи Ñайлов в _utf8_.
* [File::Find::Age](https://metacpan.org/pod/File::Find::Age) â ÑоÑÑиÑÑÐµÑ ÑÐ°Ð¹Ð»Ñ Ð¿Ð¾ вÑемени модиÑикаÑии (наÑледÑÐµÑ [File::Find::Rule](https://metacpan.org/pod/File::Find::Rule)): `File::Find::Age->in($dir1,...
* [File::Find::Declare](https://metacpan.org/pod/File::Find::Declare) â `@paths = File::Find::Declare->new({ size => '>10K', perms => 'wr-wr-wr-', modified => '<2010-01-30', recurse => 1, dirs => [$dir1] })->find`.
* [File::Find::Iterator](https://metacpan.org/pod/File::Find::Iterator) â Ð¸Ð¼ÐµÐµÑ ÐÐРинÑеÑÑÐµÐ¹Ñ Ñ Ð¸ÑеÑаÑоÑом и ÑÑнкÑии `imap` и `igrep`.
* [File::Find::Match](https://metacpan.org/pod/File::Find::Match) â вÑзÑÐ²Ð°ÐµÑ Ð¾Ð±ÑабоÑÑик на каждÑй подоÑедÑий ÑилÑÑÑ. ÐоÑ
ож на `switch`.
* [File::Find::Node](https://metacpan.org/pod/File::Find::Node) â обÑ
Ð¾Ð´Ð¸Ñ Ð¸ÐµÑаÑÑ
Ð¸Ñ Ñайлов паÑаллелÑно неÑколÑкими пÑоÑеÑÑами: `tie @paths, IPC::Shareable, { key => "GLUE STRING", create => 1 }; F...
* [File::Find::Fast](https://metacpan.org/pod/File::Find::Fast) â `@paths = @{ find($dir) }`.
* [File::Find::Object](https://metacpan.org/pod/File::Find::Object) â Ð¸Ð¼ÐµÐµÑ ÐÐРинÑеÑÑÐµÐ¹Ñ Ñ Ð¸ÑеÑаÑоÑом.
* [File::Find::Parallel](https://metacpan.org/pod/File::Find::Parallel) â ÑÐ¼ÐµÐµÑ ÑÑавниваÑÑ Ð´Ð²Ð° каÑалога и возвÑаÑаÑÑ Ð¸Ñ
обÑединение, пеÑеÑеÑение и колиÑеÑÑвенное пеÑеÑ...
* [File::Find::Random](https://metacpan.org/pod/File::Find::Random) â вÑбиÑÐ°ÐµÑ Ñайл или диÑекÑоÑÐ¸Ñ Ð½Ð°Ñгад из иеÑаÑÑ
ии Ñайлов.
* [File::Find::Rex](https://metacpan.org/pod/File::Find::Rex) â `@paths = File::Find::Rex->new(recursive => 1, ignore_hidden => 1)->query($dir, qr/^b/i)`.
* [File::Find::Rule](https://metacpan.org/pod/File::Find::Rule) â `@files = File::Find::Rule->any( File::Find::Rule->file->name('*.mp3', '*.ogg')->size('>2M'), File::Find::Rule->empty )->in($dir1, $dir2);`. ÐÐ¼ÐµÐµÑ Ð¸ÑеÑаÑоÑ, пÑоÑед...
* [File::Find::Wanted](https://metacpan.org/pod/File::Find::Wanted) â `@paths = find_wanted( sub { -f && /\.png/ }, $dir )`.
* [File::Hotfolder](https://metacpan.org/pod/File::Hotfolder) â `watch( $dir, callback => sub { push @paths, shift } )->loop`. РабоÑÐ°ÐµÑ Ð½Ð° `AnyEvent`. ÐаÑÑÑаиваемÑй. ÐÑÑÑ ÑаÑпаÑаллеливание на неÑко...
* [File::Mirror](https://metacpan.org/pod/File::Mirror) â ÑоÑмиÑÑÐµÑ Ñак же паÑаллелÑнÑй пÑÑÑ Ð´Ð»Ñ ÐºÐ¾Ð¿Ð¸ÑÐ¾Ð²Ð°Ð½Ð¸Ñ Ñайлов: `recursive { my ($src, $dst) = @_; push @paths, $src } '/path/A', '/path/B'`.
* [File::Set](https://metacpan.org/pod/File::Set) â `$fs = File::Set->new; $fs->add($dir); @paths = map { $_->[0] } $fs->get_path_list`.
* [File::Wildcard](https://metacpan.org/pod/File::Wildcard) â `$fw = File::Wildcard->new(exclude => qr/.svn/, case_insensitive => 1, sort => 1, path => "src///*.cpp", match => qr(^src/(.*?)\.cpp$), derive => ['src/$1.o','src/$1.hpp']); push @paths,...
* [File::Wildcard::Find](https://metacpan.org/pod/File::Wildcard::Find) â `findbegin($dir); push @paths, $f while $f = findnext()` или `findbegin($dir); @paths = findall()`.
* [File::Util](https://metacpan.org/pod/File::Util) â `File::Util->new->list_dir($dir, qw/ --pattern=\.txt$ --files-only --recurse /)`.
* [Mojo::File](https://metacpan.org/pod/Mojo::File) â `say for path($path)->list_tree({hidden => 1, dir => 1})->each`.
* [Path::Find](https://metacpan.org/pod/Path::Find) â `@paths = path_find( $dir, "*.png" )`. ÐÐ»Ñ ÑложнÑÑ
запÑоÑов иÑполÑзÑÐµÑ _matchable_: `my $sub = matchable( sub { my( $entry, $directory, $fullname, $depth ) = @_; $dep...
* [Path::Extended::Dir](https://metacpan.org/pod/Path::Extended::Dir) â `@paths = Path::Extended::Dir->new($dir)->find('*.txt')`.
* [Path::Iterator::Rule](https://metacpan.org/pod/Path::Iterator::Rule) â `$i = Path::Iterator::Rule->new->file; @paths = $i->clone->size(">10k")->all(@dirs); $i->size("<10k")...`.
* [Path::Class::Each](https://metacpan.org/pod/Path::Class::Each) â `dir($dir)->each(sub { push @paths, "$_" })`.
* [Path::Class::Iterator](https://metacpan.org/pod/Path::Class::Iterator) â `$i = Path::Class::Iterator->new(root => $dir, depth => 2); until ($i->done) { push @paths, $i->next->stringify }`.
* [Path::Class::Rule](https://metacpan.org/pod/Path::Class::Rule) â `@paths = Path::Class::Rule->new->file->size(">10k")->all($dir)`.
lib/Aion/Fs.md view on Meta::CPAN
Файл lib/N.pm:
```perl
package N;
sub ex { 123 }
1;
```
```perl
use lib "lib";
include("A")->new # ~> A=HASH\(0x\w+\)
[map include, qw/A N/] # --> [qw/A N/]
{ local $_="N"; include->ex } # -> 123
```
## catonce (;$file)
СÑиÑÑÐ²Ð°ÐµÑ Ñайл в пеÑвÑй Ñаз. ÐÑÐ±Ð°Ñ Ð¿Ð¾ÑледÑÑÑÐ°Ñ Ð¿Ð¾Ð¿ÑÑка ÑÑиÑаÑÑ ÑÑÐ¾Ñ Ñайл возвÑаÑÐ°ÐµÑ `undef`. ÐÑполÑзÑеÑÑÑ Ð´Ð»Ñ Ð²ÑÑавки модÑлей js и css в ÑезÑлÑ...
* `$file` Ð¼Ð¾Ð¶ÐµÑ ÑодеÑжаÑÑ Ð¼Ð°ÑÑÐ¸Ð²Ñ Ð¸Ð· двÑÑ
ÑлеменÑов. ÐеÑвÑй ÑаÑÑмаÑÑиваеÑÑÑ ÐºÐ°Ðº пÑÑÑ, а вÑоÑой â как Ñлой. Слой по ÑмолÑÐ°Ð½Ð¸Ñ â `:utf8`.
* ÐÑли `$file` не Ñказан â иÑполÑзÑÐµÑ `$_`.
lib/Aion/Fs.md view on Meta::CPAN
eval { goto_editor "`", 1 }; $@ # ~> `:1 --> 512
```
## from_pkg (;$pkg)
ÐеÑÐµÐ²Ð¾Ð´Ð¸Ñ Ð¿Ð°ÐºÐµÑ Ð² пÑÑÑ Ð¤Ð¡. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
```perl
from_pkg "Aion::Fs" # => Aion/Fs.pm
[map from_pkg, "Aion::Fs", "A::B::C"] # --> ["Aion/Fs.pm", "A/B/C.pm"]
```
## to_pkg (;$path)
ÐеÑÐµÐ²Ð¾Ð´Ð¸Ñ Ð¿ÑÑÑ Ð¸Ð· ФС в пакеÑ. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
```perl
to_pkg "Aion/Fs.pm" # => Aion::Fs
[map to_pkg, "Aion/Fs.md", "A/B/C.md"] # --> ["Aion::Fs", "A::B::C"]
```
## from_inc (;$pkg)
ÐеÑÐµÐ²Ð¾Ð´Ð¸Ñ Ð¿Ð°ÐºÐµÑ Ð² пÑÑÑ Ð¤Ð¡ в `@INC`. Файл Ñ Ð¿Ð°ÐºÐµÑом должен ÑÑÑеÑÑвоваÑÑ Ð² одном из пÑÑей `@INC`. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
```perl
from_inc "Aion::Fs" # -> $INC{'Aion/Fs.pm'}
[map from_inc, "A::B::C", "Aion::Fs"] # --> [$INC{'Aion/Fs.pm'}]
from_inc "A::B::C" # -> undef
```
## to_inc (;$path)
ÐеÑÐµÐ²Ð¾Ð´Ð¸Ñ Ð¿ÑÑÑ Ð¸Ð· ФС в `@INC` в пакеÑ. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
```perl
to_inc $INC{'Aion/Fs.pm'} # => Aion::Fs
[map to_inc,"A/B/C.pm", $INC{'Aion/Fs.pm'}] # --> ["Aion::Fs"]
to_inc 'Aion/Fs.pm' # -> undef
```
## ilay (;$path)
СоздаÑÑ ÑайловÑй деÑкÑипÑоÑ. Ðн ÑÐ¼ÐµÐµÑ Ð·Ð°ÐºÑÑваÑÑÑÑ, как ÑолÑко на него иÑÑÐµÐ·Ð½ÐµÑ Ð¿Ð¾ÑледнÑÑ ÑÑÑлка.
Так же Ð¸Ð¼ÐµÐµÑ Ð¼ÐµÑод `path`, к-й возвÑаÑÐ°ÐµÑ Ð¿ÑÑÑ Ðº ÑайлÑ.
lib/Aion/Fs.pm view on Meta::CPAN
delete @res{keys %{$fs->{remove}->{$_}}} for @remove;
return %res, %$_;
}
sub _join(@) {
my ($match, @format) = @_;
my $fs = _fs;
my $trans = $fs->{before_split} // sub {$_[0]};
my %f = _match $match, $fs;
join "", List::Util::pairmap {
my @keys = ref $a? @$a: $a;
my $is = List::Util::first {defined $f{$_}} @keys;
defined $is? do {
my ($if, $format) = ref $b? @$b: (undef, $b);
my @val = map $trans->($f{$_}), @keys;
defined $if && $val[0] eq $if? $if:
$format !~ /%s/? $format:
sprintf($format, @val)
}: ()
} @format
}
# СинÑакÑиÑÑ ÑайловÑÑ
пÑÑей в ÑазнÑÑ
ÐС
my %FS;
my @FS = (
lib/Aion/Fs.pm view on Meta::CPAN
\z!xsn,
join => sub {
_join [qw/path/],
[qw/userid file ext volume/] => "%s %s %s %s",
},
},
);
# ÐниÑиализаÑÐ¸Ñ Ð¿Ð¾ имени
%FS = map {
$_->{symdirquote} = quotemeta $_->{symdir};
$_->{symextquote} = quotemeta $_->{symext};
my @S;
while($_->{regexp} =~ m{
\\ .
| (?<open> \( ( \?<(?<group> \w+ )> )? )
| (?<close> \) )
}gx) {
if($+{open}) {
lib/Aion/Fs.pm view on Meta::CPAN
$group //= $g2;
$_->{group}{$group} = do {
my $x = substr $_->{regexp}, $pos, length($`) - $pos;
qr/()^$x\z/xsn
} if defined $group;
}
}
my $x = $_;
ref $_->{name}? (map { ($_ => $x) } @{$_->{name}}): ($_->{name} => $_)
} @FS;
sub _fs() { $FS{lc $^O} // $FS{unix} }
# ÐÑ Ð½Ð°Ñ
одимÑÑ Ð² ÐС ÑемейÑÑва UNIX
sub isUNIX() { _fs->{name} eq "unix" }
# Ð Ð°Ð·Ð±Ð¸Ð²Ð°ÐµÑ Ð´Ð¸ÑекÑоÑÐ¸Ñ Ð½Ð° ÑоÑÑавлÑÑÑие
sub splitdir(;$) {
my ($dir) = @_ == 0? $_: @_;
lib/Aion/Fs.pm view on Meta::CPAN
if(ref $path eq "HASH") {
local $_ = $path;
return $fs->{join}->();
}
($path) = @$path if ref $path;
$path = $fs->{before_split}->($path) if exists $fs->{before_split};
+{
$path =~ $fs->{regexp}? (map { $_ ne "ext" && $+{$_} eq ""? (): ($_ => $+{$_}) } keys %+): (error => 1),
path => $path,
}
}
# ÐеÑÐµÐ²Ð¾Ð´Ð¸Ñ Ð¿ÑÑÑ Ð¸Ð· ÑоÑмаÑа одной ÐС в дÑÑгÑÑ
sub transpath ($$;$) {
my ($path, $from, $to) = @_ == 2? ($_, @_): @_;
my (@dir, @folder, @ext);
{ local $^O = $from;
$path = path $path;
lib/Aion/Fs.pm view on Meta::CPAN
# group_can_exec group_can_read group_can_write
# other_can_exec other_can_read other_can_write
# /} = (
#
# );
\%sta
}
# ФайловÑе ÑилÑÑÑÑ
sub _filters(@) {
map {
if(ref $_ eq "CODE") {$_}
elsif(ref $_ eq "Regexp") { my $re = $_; sub { $_ =~ $re } }
elsif(/^-([a-z]+)$/) {
eval join "", "sub { ", (join " && ", map "-$_()", split //, $1), " }"
}
else { my $re = wildcard(); sub { $_ =~ $re } }
} @_
}
# ÐайÑи ÑайлÑ
sub find(;@) {
my $files = @_? shift: $_;
$files = [$files] unless ref $files;
lib/Aion/Fs.pm view on Meta::CPAN
return $path if -f $path;
}
return;
}
# Ðз Ñайлового пÑÑи в @INC в пакеÑ
sub to_inc(;$) {
my ($path) = @_ == 0? $_: @_;
my $inc = join "|", map quotemeta, @INC;
return to_pkg $' if $path =~ m!^(?:$inc)/!;
return;
}
# ÐодклÑÑÐ°ÐµÑ Ð¼Ð¾Ð´ÑлÑ, еÑли он еÑÑ Ð½Ðµ подклÑÑÑн, и возвÑаÑÐ°ÐµÑ ÐµÐ³Ð¾
sub include(;$) {
my ($pkg) = @_ == 0? $_: @_;
return $pkg if $pkg->can("new") || $pkg->can("has");
lib/Aion/Fs.pm view on Meta::CPAN
use Aion::Fs;
lay mkpath "hello/world.txt", "hi!";
lay mkpath "hello/moon.txt", "noreplace";
lay mkpath "hello/big/world.txt", "hellow!";
lay mkpath "hello/small/world.txt", "noenter";
mtime "hello"; # ~> ^\d+(\.\d+)?$
[map cat, grep -f, find ["hello/big", "hello/small"]]; # --> [qw/ hellow! noenter /]
my @noreplaced = replace { s/h/$a $b H/ }
find "hello", "-f", "*.txt", qr/\.txt$/, sub { /\.txt$/ },
noenter "*small*",
errorenter { warn "find $_: $!" };
\@noreplaced; # --> ["hello/moon.txt"]
cat "hello/world.txt"; # => hello/world.txt :utf8 Hi!
cat "hello/moon.txt"; # => noreplace
lib/Aion/Fs.pm view on Meta::CPAN
$count # -> 3
=head3 See also
=over
=item * L<AudioFile::Find> â searches for audio files in the specified directory. Allows you to filter them by attributes: title, artist, genre, album and track.
=item * L<Directory::Iterator> â C<< $it = Directory::Iterator-E<gt>new($dir, %opts); push @paths, $_ while E<lt>$itE<gt> >>.
=item * L<IO::All> â C<< @paths = map { "$_" } grep { -f $_ && $_-E<gt>size E<gt> 10*1024 } io(".")-E<gt>all(0) >>.
=item * L<IO::All::Rule> â C<< $next = IO::All::Rule-E<gt>new-E<gt>file-E<gt>size("E<gt>10k")-E<gt>iter($dir1, $dir2); push @paths, "$f" while $f = $next-E<gt>() >>.
=item * L<File::Find> â C<find( sub { push @paths, $File::Find::name if /\.png/ }, $dir )>.
=item * L<File::Find::utf8> â like L<File::Find>, only file paths are in I<utf8>.
=item * L<File::Find::Age> â sorts files by modification time (inherits L<File::Find::Rule>): C<< File::Find::Age-E<gt>in($dir1, $dir2) >>.
=item * L<File::Find::Declare> â C<< @paths = File::Find::Declare-E<gt>new({ size =E<gt> 'E<gt>10K', perms =E<gt> 'wr-wr-wr-', modified =E<gt> 'E<lt>2010-01-30', recurse =E<gt> 1, dirs =E<gt> [$dir1] })-E<gt>find >>.
=item * L<File::Find::Iterator> â has an OOP interface with an iterator and the C<imap> and C<igrep> functions.
=item * L<File::Find::Match> â calls a handler for each matching filter. Similar to C<switch>.
=item * L<File::Find::Node> â traverses the file hierarchy in parallel by several processes: C<< tie @paths, IPC::Shareable, { key =E<gt> "GLUE STRING", create =E<gt> 1 }; File::Find::Node-E<gt>new(".")-E<gt>process(sub { my $f = shift; $f-E<gt>for...
=item * L<File::Find::Fast> â C<@paths = @{ find($dir) }>.
=item * L<File::Find::Object> â has an OOP interface with an iterator.
=item * L<File::Find::Parallel> â can compare two directories and return their union, intersection and quantitative intersection.
lib/Aion/Fs.pm view on Meta::CPAN
=item * L<File::Find::Rex> â C<< @paths = File::Find::Rex-E<gt>new(recursive =E<gt> 1, ignore_hidden =E<gt> 1)-E<gt>query($dir, qr/^b/i) >>.
=item * L<File::Find::Rule> â C<< @files = File::Find::Rule-E<gt>any( File::Find::Rule-E<gt>file-E<gt>name('*.mp3', '*.ogg')-E<gt>size('E<gt>2M'), File::Find::Rule-E<gt>empty )-E<gt>in($dir1, $dir2); >>. Has an iterator, procedural interface and ex...
=item * L<File::Find::Wanted> â C<@paths = find_wanted( sub { -f && /\.png/ }, $dir )>.
=item * L<File::Hotfolder> â C<< watch( $dir, callback =E<gt> sub { push @paths, shift } )-E<gt>loop >>. Powered by C<AnyEvent>. Customizable. There is parallelization into several processes.
=item * L<File::Mirror> â also forms a parallel path for copying files: C<recursive { my ($src, $dst) = @_; push @paths, $src } '/path/A', '/path/B'>.
=item * L<File::Set> â C<< $fs = File::Set-E<gt>new; $fs-E<gt>add($dir); @paths = map { $_-E<gt>[0] } $fs-E<gt>get_path_list >>.
=item * L<File::Wildcard> â C<< $fw = File::Wildcard-E<gt>new(exclude =E<gt> qr/.svn/, case_insensitive =E<gt> 1, sort =E<gt> 1, path =E<gt> "src///*.cpp", match =E<gt> qr(^src/(.*?)\.cpp$), derive =E<gt> ['src/$1.o','src/$1.hpp']); push @paths, $f...
=item * L<File::Wildcard::Find> â C<findbegin($dir); push @paths, $f while $f = findnext()> or C<findbegin($dir); @paths = findall()>.
=item * L<File::Util> â C<< File::Util-E<gt>new-E<gt>list_dir($dir, qw/ --pattern=\.txt$ --files-only --recurse /) >>.
=item * L<Mojo::File> â C<< say for path($path)-E<gt>list_tree({hidden =E<gt> 1, dir =E<gt> 1})-E<gt>each >>.
=item * L<Path::Find> â C<@paths = path_find( $dir, "*.png" )>. For complex queries, use I<matchable>: C<< my $sub = matchable( sub { my( $entry, $directory, $fullname, $depth ) = @_; $depth E<lt>= 3 } >>.
lib/Aion/Fs.pm view on Meta::CPAN
lib/N.pm file:
package N;
sub ex { 123 }
1;
use lib "lib";
include("A")->new # ~> A=HASH\(0x\w+\)
[map include, qw/A N/] # --> [qw/A N/]
{ local $_="N"; include->ex } # -> 123
=head2 catonce (;$file)
Reads the file for the first time. Any subsequent attempt to read this file returns C<undef>. Used to insert js and css modules into the resulting file. Without a parameter, uses C<$_>.
=over
=item * C<$file> can contain arrays of two elements. The first is considered as a path, and the second as a layer. The default layer is C<:utf8>.
lib/Aion/Fs.pm view on Meta::CPAN
goto_editor "mypath", 10;
cat "ed.txt" # => mypath:10\n
eval { goto_editor "`", 1 }; $@ # ~> `:1 --> 512
=head2 from_pkg (;$pkg)
Transfers the packet to the FS path. Without a parameter, uses C<$_>.
from_pkg "Aion::Fs" # => Aion/Fs.pm
[map from_pkg, "Aion::Fs", "A::B::C"] # --> ["Aion/Fs.pm", "A/B/C.pm"]
=head2 to_pkg (;$path)
Translates the path from the FS to the package. Without a parameter, uses C<$_>.
to_pkg "Aion/Fs.pm" # => Aion::Fs
[map to_pkg, "Aion/Fs.md", "A/B/C.md"] # --> ["Aion::Fs", "A::B::C"]
=head2 from_inc (;$pkg)
Translates the packet to the FS path in C<@INC>. The package file must exist in one of the C<@INC> paths. Without a parameter, uses C<$_>.
from_inc "Aion::Fs" # -> $INC{'Aion/Fs.pm'}
[map from_inc, "A::B::C", "Aion::Fs"] # --> [$INC{'Aion/Fs.pm'}]
from_inc "A::B::C" # -> undef
=head2 to_inc (;$path)
Translates the path from FS to C<@INC> into a package. Without a parameter, uses C<$_>.
to_inc $INC{'Aion/Fs.pm'} # => Aion::Fs
[map to_inc,"A/B/C.pm", $INC{'Aion/Fs.pm'}] # --> ["Aion::Fs"]
to_inc 'Aion/Fs.pm' # -> undef
=head2 ilay (;$path)
Creates a file descriptor. It knows how to close as soon as the last link to it disappears.
It also has a C<path> method, which returns the path to the file.
my $test_file = "test_ilay_complete.txt";
t/aion/fs.t view on Meta::CPAN
subtest 'SYNOPSIS' => sub {
use Aion::Fs;
lay mkpath "hello/world.txt", "hi!";
lay mkpath "hello/moon.txt", "noreplace";
lay mkpath "hello/big/world.txt", "hellow!";
lay mkpath "hello/small/world.txt", "noenter";
::like scalar do {mtime "hello";}, qr{^\d+(\.\d+)?$}, 'mtime "hello"; # ~> ^\d+(\.\d+)?$'; undef $::_g0; undef $::_e0;
local ($::_g0 = do {[map cat, grep -f, find ["hello/big", "hello/small"]];}, $::_e0 = do {[qw/ hellow! noenter /]}); ::is_deeply $::_g0, $::_e0, '[map cat, grep -f, find ["hello/big", "hello/small"]]; # --> [qw/ hellow! noenter /]' or ::diag ::_stru...
my @noreplaced = replace { s/h/$a $b H/ }
find "hello", "-f", "*.txt", qr/\.txt$/, sub { /\.txt$/ },
noenter "*small*",
errorenter { warn "find $_: $!" };
local ($::_g0 = do {\@noreplaced;}, $::_e0 = do {["hello/moon.txt"]}); ::is_deeply $::_g0, $::_e0, '\@noreplaced; # --> ["hello/moon.txt"]' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {cat "hello/world.txt";}, $::_e0 = "hello/world.txt :utf8 Hi!"); ::ok $::_g0 eq $::_e0, 'cat "hello/world.txt"; # => hello/world.txt :utf8 Hi!' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {cat "hello/moon.txt";}, $::_e0 = "noreplace"); ::ok $::_g0 eq $::_e0, 'cat "hello/moon.txt"; # => noreplace' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
t/aion/fs.t view on Meta::CPAN
my $count = 0;
find "ex", sub { find_stop if ++$count == 3; 1};
local ($::_g0 = do {$count}, $::_e0 = do {3}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '$count # -> 3' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# ### See also
#
# * [AudioFile::Find](https://metacpan.org/pod/AudioFile::Find) â иÑÐµÑ Ð°ÑдиоÑÐ°Ð¹Ð»Ñ Ð² Ñказанной диÑекÑоÑии. ÐозволÑÐµÑ ÑилÑÑÑоваÑÑ Ð¸Ñ
по аÑÑибÑÑам: названиÑ, аÑÑиÑÑÑ, ж...
# * [Directory::Iterator](https://metacpan.org/pod/Directory::Iterator) â `$it = Directory::Iterator->new($dir, %opts); push @paths, $_ while <$it>`.
# * [IO::All](https://metacpan.org/pod/IO::All) â `@paths = map { "$_" } grep { -f $_ && $_->size > 10*1024 } io(".")->all(0)`.
# * [IO::All::Rule](https://metacpan.org/pod/IO::All::Rule) â `$next = IO::All::Rule->new->file->size(">10k")->iter($dir1, $dir2); push @paths, "$f" while $f = $next->()`.
# * [File::Find](https://metacpan.org/pod/File::Find) â `find( sub { push @paths, $File::Find::name if /\.png/ }, $dir )`.
# * [File::Find::utf8](https://metacpan.org/pod/File::Find::utf8) â как [File::Find](https://metacpan.org/pod/File::Find), ÑолÑко пÑÑи Ñайлов в _utf8_.
# * [File::Find::Age](https://metacpan.org/pod/File::Find::Age) â ÑоÑÑиÑÑÐµÑ ÑÐ°Ð¹Ð»Ñ Ð¿Ð¾ вÑемени модиÑикаÑии (наÑледÑÐµÑ [File::Find::Rule](https://metacpan.org/pod/File::Find::Rule)): `File::Find::Age->in($dir...
# * [File::Find::Declare](https://metacpan.org/pod/File::Find::Declare) â `@paths = File::Find::Declare->new({ size => '>10K', perms => 'wr-wr-wr-', modified => '<2010-01-30', recurse => 1, dirs => [$dir1] })->find`.
# * [File::Find::Iterator](https://metacpan.org/pod/File::Find::Iterator) â Ð¸Ð¼ÐµÐµÑ ÐÐРинÑеÑÑÐµÐ¹Ñ Ñ Ð¸ÑеÑаÑоÑом и ÑÑнкÑии `imap` и `igrep`.
# * [File::Find::Match](https://metacpan.org/pod/File::Find::Match) â вÑзÑÐ²Ð°ÐµÑ Ð¾Ð±ÑабоÑÑик на каждÑй подоÑедÑий ÑилÑÑÑ. ÐоÑ
ож на `switch`.
# * [File::Find::Node](https://metacpan.org/pod/File::Find::Node) â обÑ
Ð¾Ð´Ð¸Ñ Ð¸ÐµÑаÑÑ
Ð¸Ñ Ñайлов паÑаллелÑно неÑколÑкими пÑоÑеÑÑами: `tie @paths, IPC::Shareable, { key => "GLUE STRING", create => 1 };...
# * [File::Find::Fast](https://metacpan.org/pod/File::Find::Fast) â `@paths = @{ find($dir) }`.
# * [File::Find::Object](https://metacpan.org/pod/File::Find::Object) â Ð¸Ð¼ÐµÐµÑ ÐÐРинÑеÑÑÐµÐ¹Ñ Ñ Ð¸ÑеÑаÑоÑом.
# * [File::Find::Parallel](https://metacpan.org/pod/File::Find::Parallel) â ÑÐ¼ÐµÐµÑ ÑÑавниваÑÑ Ð´Ð²Ð° каÑалога и возвÑаÑаÑÑ Ð¸Ñ
обÑединение, пеÑеÑеÑение и колиÑеÑÑвенное пеÑе...
# * [File::Find::Random](https://metacpan.org/pod/File::Find::Random) â вÑбиÑÐ°ÐµÑ Ñайл или диÑекÑоÑÐ¸Ñ Ð½Ð°Ñгад из иеÑаÑÑ
ии Ñайлов.
# * [File::Find::Rex](https://metacpan.org/pod/File::Find::Rex) â `@paths = File::Find::Rex->new(recursive => 1, ignore_hidden => 1)->query($dir, qr/^b/i)`.
# * [File::Find::Rule](https://metacpan.org/pod/File::Find::Rule) â `@files = File::Find::Rule->any( File::Find::Rule->file->name('*.mp3', '*.ogg')->size('>2M'), File::Find::Rule->empty )->in($dir1, $dir2);`. ÐÐ¼ÐµÐµÑ Ð¸ÑеÑаÑоÑ, пÑоÑе...
# * [File::Find::Wanted](https://metacpan.org/pod/File::Find::Wanted) â `@paths = find_wanted( sub { -f && /\.png/ }, $dir )`.
# * [File::Hotfolder](https://metacpan.org/pod/File::Hotfolder) â `watch( $dir, callback => sub { push @paths, shift } )->loop`. РабоÑÐ°ÐµÑ Ð½Ð° `AnyEvent`. ÐаÑÑÑаиваемÑй. ÐÑÑÑ ÑаÑпаÑаллеливание на неÑк...
# * [File::Mirror](https://metacpan.org/pod/File::Mirror) â ÑоÑмиÑÑÐµÑ Ñак же паÑаллелÑнÑй пÑÑÑ Ð´Ð»Ñ ÐºÐ¾Ð¿Ð¸ÑÐ¾Ð²Ð°Ð½Ð¸Ñ Ñайлов: `recursive { my ($src, $dst) = @_; push @paths, $src } '/path/A', '/path/B'`.
# * [File::Set](https://metacpan.org/pod/File::Set) â `$fs = File::Set->new; $fs->add($dir); @paths = map { $_->[0] } $fs->get_path_list`.
# * [File::Wildcard](https://metacpan.org/pod/File::Wildcard) â `$fw = File::Wildcard->new(exclude => qr/.svn/, case_insensitive => 1, sort => 1, path => "src///*.cpp", match => qr(^src/(.*?)\.cpp$), derive => ['src/$1.o','src/$1.hpp']); push @path...
# * [File::Wildcard::Find](https://metacpan.org/pod/File::Wildcard::Find) â `findbegin($dir); push @paths, $f while $f = findnext()` или `findbegin($dir); @paths = findall()`.
# * [File::Util](https://metacpan.org/pod/File::Util) â `File::Util->new->list_dir($dir, qw/ --pattern=\.txt$ --files-only --recurse /)`.
# * [Mojo::File](https://metacpan.org/pod/Mojo::File) â `say for path($path)->list_tree({hidden => 1, dir => 1})->each`.
# * [Path::Find](https://metacpan.org/pod/Path::Find) â `@paths = path_find( $dir, "*.png" )`. ÐÐ»Ñ ÑложнÑÑ
запÑоÑов иÑполÑзÑÐµÑ _matchable_: `my $sub = matchable( sub { my( $entry, $directory, $fullname, $depth ) = @_; $d...
# * [Path::Extended::Dir](https://metacpan.org/pod/Path::Extended::Dir) â `@paths = Path::Extended::Dir->new($dir)->find('*.txt')`.
# * [Path::Iterator::Rule](https://metacpan.org/pod/Path::Iterator::Rule) â `$i = Path::Iterator::Rule->new->file; @paths = $i->clone->size(">10k")->all(@dirs); $i->size("<10k")...`.
# * [Path::Class::Each](https://metacpan.org/pod/Path::Class::Each) â `dir($dir)->each(sub { push @paths, "$_" })`.
# * [Path::Class::Iterator](https://metacpan.org/pod/Path::Class::Iterator) â `$i = Path::Class::Iterator->new(root => $dir, depth => 2); until ($i->done) { push @paths, $i->next->stringify }`.
# * [Path::Class::Rule](https://metacpan.org/pod/Path::Class::Rule) â `@paths = Path::Class::Rule->new->file->size(">10k")->all($dir)`.
t/aion/fs.t view on Meta::CPAN
# Файл lib/N.pm:
#@> lib/N.pm
#>> package N;
#>> sub ex { 123 }
#>> 1;
#@< EOF
#
::done_testing; }; subtest 'include (;$pkg)' => sub {
use lib "lib";
::like scalar do {include("A")->new}, qr{A=HASH\(0x\w+\)}, 'include("A")->new # ~> A=HASH\(0x\w+\)'; undef $::_g0; undef $::_e0;
local ($::_g0 = do {[map include, qw/A N/]}, $::_e0 = do {[qw/A N/]}); ::is_deeply $::_g0, $::_e0, '[map include, qw/A N/] # --> [qw/A N/]' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {{ local $_="N"; include->ex }}, $::_e0 = do {123}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, '{ local $_="N"; include->ex } # -> 123' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# ## catonce (;$file)
#
# СÑиÑÑÐ²Ð°ÐµÑ Ñайл в пеÑвÑй Ñаз. ÐÑÐ±Ð°Ñ Ð¿Ð¾ÑледÑÑÑÐ°Ñ Ð¿Ð¾Ð¿ÑÑка ÑÑиÑаÑÑ ÑÑÐ¾Ñ Ñайл возвÑаÑÐ°ÐµÑ `undef`. ÐÑполÑзÑеÑÑÑ Ð´Ð»Ñ Ð²ÑÑавки модÑлей js и css в ÑезÑÐ...
#
# * `$file` Ð¼Ð¾Ð¶ÐµÑ ÑодеÑжаÑÑ Ð¼Ð°ÑÑÐ¸Ð²Ñ Ð¸Ð· двÑÑ
ÑлеменÑов. ÐеÑвÑй ÑаÑÑмаÑÑиваеÑÑÑ ÐºÐ°Ðº пÑÑÑ, а вÑоÑой â как Ñлой. Слой по ÑмолÑÐ°Ð½Ð¸Ñ â `:utf8`.
# * ÐÑли `$file` не Ñказан â иÑполÑзÑÐµÑ `$_`.
#
t/aion/fs.t view on Meta::CPAN
::like scalar do {eval { goto_editor "`", 1 }; $@}, qr{`:1 --> 512}, 'eval { goto_editor "`", 1 }; $@ # ~> `:1 --> 512'; undef $::_g0; undef $::_e0;
#
# ## from_pkg (;$pkg)
#
# ÐеÑÐµÐ²Ð¾Ð´Ð¸Ñ Ð¿Ð°ÐºÐµÑ Ð² пÑÑÑ Ð¤Ð¡. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
#
::done_testing; }; subtest 'from_pkg (;$pkg)' => sub {
local ($::_g0 = do {from_pkg "Aion::Fs"}, $::_e0 = "Aion/Fs.pm"); ::ok $::_g0 eq $::_e0, 'from_pkg "Aion::Fs" # => Aion/Fs.pm' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {[map from_pkg, "Aion::Fs", "A::B::C"]}, $::_e0 = do {["Aion/Fs.pm", "A/B/C.pm"]}); ::is_deeply $::_g0, $::_e0, '[map from_pkg, "Aion::Fs", "A::B::C"] # --> ["Aion/Fs.pm", "A/B/C.pm"]' or ::diag ::_struct_diff($::_g0, $::_e0); und...
#
# ## to_pkg (;$path)
#
# ÐеÑÐµÐ²Ð¾Ð´Ð¸Ñ Ð¿ÑÑÑ Ð¸Ð· ФС в пакеÑ. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
#
::done_testing; }; subtest 'to_pkg (;$path)' => sub {
local ($::_g0 = do {to_pkg "Aion/Fs.pm"}, $::_e0 = "Aion::Fs"); ::ok $::_g0 eq $::_e0, 'to_pkg "Aion/Fs.pm" # => Aion::Fs' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {[map to_pkg, "Aion/Fs.md", "A/B/C.md"]}, $::_e0 = do {["Aion::Fs", "A::B::C"]}); ::is_deeply $::_g0, $::_e0, '[map to_pkg, "Aion/Fs.md", "A/B/C.md"] # --> ["Aion::Fs", "A::B::C"]' or ::diag ::_struct_diff($::_g0, $::_e0); undef $...
#
# ## from_inc (;$pkg)
#
# ÐеÑÐµÐ²Ð¾Ð´Ð¸Ñ Ð¿Ð°ÐºÐµÑ Ð² пÑÑÑ Ð¤Ð¡ в `@INC`. Файл Ñ Ð¿Ð°ÐºÐµÑом должен ÑÑÑеÑÑвоваÑÑ Ð² одном из пÑÑей `@INC`. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
#
::done_testing; }; subtest 'from_inc (;$pkg)' => sub {
local ($::_g0 = do {from_inc "Aion::Fs"}, $::_e0 = do {$INC{'Aion/Fs.pm'}}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, 'from_inc "Aion::Fs" # -> $INC{\'Aion/Fs.pm\'}' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $:...
local ($::_g0 = do {[map from_inc, "A::B::C", "Aion::Fs"]}, $::_e0 = do {[$INC{'Aion/Fs.pm'}]}); ::is_deeply $::_g0, $::_e0, '[map from_inc, "A::B::C", "Aion::Fs"] # --> [$INC{\'Aion/Fs.pm\'}]' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0;...
local ($::_g0 = do {from_inc "A::B::C"}, $::_e0 = do {undef}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, 'from_inc "A::B::C" # -> undef' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# ## to_inc (;$path)
#
# ÐеÑÐµÐ²Ð¾Ð´Ð¸Ñ Ð¿ÑÑÑ Ð¸Ð· ФС в `@INC` в пакеÑ. Ðез паÑамеÑÑа иÑполÑзÑÐµÑ `$_`.
#
::done_testing; }; subtest 'to_inc (;$path)' => sub {
local ($::_g0 = do {to_inc $INC{'Aion/Fs.pm'}}, $::_e0 = "Aion::Fs"); ::ok $::_g0 eq $::_e0, 'to_inc $INC{\'Aion/Fs.pm\'} # => Aion::Fs' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {[map to_inc,"A/B/C.pm", $INC{'Aion/Fs.pm'}]}, $::_e0 = do {["Aion::Fs"]}); ::is_deeply $::_g0, $::_e0, '[map to_inc,"A/B/C.pm", $INC{\'Aion/Fs.pm\'}] # --> ["Aion::Fs"]' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; und...
local ($::_g0 = do {to_inc 'Aion/Fs.pm'}, $::_e0 = do {undef}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, 'to_inc \'Aion/Fs.pm\' # -> undef' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# ## ilay (;$path)
#
# СоздаÑÑ ÑайловÑй деÑкÑипÑоÑ. Ðн ÑÐ¼ÐµÐµÑ Ð·Ð°ÐºÑÑваÑÑÑÑ, как ÑолÑко на него иÑÑÐµÐ·Ð½ÐµÑ Ð¿Ð¾ÑледнÑÑ ÑÑÑлка.
#
# Так же Ð¸Ð¼ÐµÐµÑ Ð¼ÐµÑод `path`, к-й возвÑаÑÐ°ÐµÑ Ð¿ÑÑÑ Ðº ÑайлÑ.
#