view release on metacpan or search on metacpan
[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
cat "hello/big/world.txt" # => hello/big/world.txt :utf8 Hellow!
cat "hello/small/world.txt" # => noenter
[find "hello", "*.txt"] # --> [qw! hello/moon.txt hello/world.txt hello/big/world.txt hello/small/world.txt !]
[find "hello", "-d"] # --> [qw! hello hello/big hello/small !]
erase reverse find "hello";
-e "hello" # -> undef
```
# SUBROUTINES/METHODS
## cat ($file)
СÑиÑÑÐ²Ð°ÐµÑ Ñайл. ÐÑли паÑамеÑÑ Ð½Ðµ Ñказан, иÑполÑзÑÐµÑ `$_`.
```perl
cat "/etc/passwd" # ~> root
```
`cat` ÑиÑÐ°ÐµÑ Ñо Ñлоем `:utf8`. Ðо можно ÑказаÑÑ Ð´ÑÑгой Ñлой ÑледÑÑÑим обÑазом:
```perl
lay "unicode.txt", "â¯";
length cat "unicode.txt" # -> 1
length cat["unicode.txt", ":raw"] # -> 3
```
`cat` вÑзÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑение в ÑлÑÑае оÑибки опеÑаÑии ввода-вÑвода:
```perl
* [File::Util](https://metacpan.org/pod/File::Util) â `File::Util->new->load_file(file => 'file.txt')`.
* [IO::All](https://metacpan.org/pod/IO::All) â `io('file.txt') > $contents`.
* [IO::Util](https://metacpan.org/pod/IO::Util) â `$contents = ${ slurp 'file.txt' }`.
* [Mojo::File](https://metacpan.org/pod/Mojo::File) â `path($file)->slurp`.
## lay ($file?, $content)
ÐапиÑÑÐ²Ð°ÐµÑ `$content` в `$file`.
* ÐÑли Ñказан один паÑамеÑÑ, иÑполÑзÑÐµÑ `$_` вмеÑÑо `$file`.
* `lay`, иÑполÑзÑÐµÑ Ñлой `:utf8`. ÐÐ»Ñ ÑÐºÐ°Ð·Ð°Ð½Ð¸Ñ Ð¸Ð½Ð¾Ð³Ð¾ ÑÐ»Ð¾Ñ Ð¸ÑполÑзÑеÑÑÑ Ð¼Ð°ÑÑив из двÑÑ
ÑлеменÑов в паÑамеÑÑе `$file`:
```perl
lay "unicode.txt", "â¯" # => unicode.txt
lay ["unicode.txt", ":raw"], "â¯" # => unicode.txt
eval { lay "/", "â¯" }; $@ # ~> lay /: Is a directory
```
### See also
find "ex", sub { find_stop if ++$count == 3; 1} # -> 2
```
### 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)`.
* `unlink` + `rmdir`.
* [File::Path](https://metacpan.org/pod/File::Path) â `remove_tree("dir")`.
* [File::Path::Tiny](https://metacpan.org/pod/File::Path::Tiny) â `File::Path::Tiny::rm($path)`. Ðе вÑбÑаÑÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑений.
* [Mojo::File](https://metacpan.org/pod/Mojo::File) â `path($file)->remove`.
## replace (&sub, @files)
ÐаменÑÐµÑ ÐºÐ°Ð¶Ð´Ñй Ñайл на `$_`, еÑли его изменÑÐµÑ `&sub`. ÐозвÑаÑÐ°ÐµÑ ÑайлÑ, в коÑоÑÑÑ
не бÑло замен.
`@files` Ð¼Ð¾Ð¶ÐµÑ ÑодеÑжаÑÑ Ð¼Ð°ÑÑÐ¸Ð²Ñ Ð¸Ð· двÑÑ
ÑлеменÑов. ÐеÑвÑй ÑаÑÑмаÑÑиваеÑÑÑ ÐºÐ°Ðº пÑÑÑ, а вÑоÑой â как Ñлой. Слой по ÑмолÑÐ°Ð½Ð¸Ñ â `:utf8`.
`&sub` вÑзÑваеÑÑÑ Ð´Ð»Ñ ÐºÐ°Ð¶Ð´Ð¾Ð³Ð¾ Ñайла из `@files`. Ð Ð½ÐµÑ Ð¿ÐµÑедаÑÑÑÑ:
* `$_` â ÑодеÑжимое Ñайла.
* `$a` â пÑÑÑ Ðº ÑайлÑ.
* `$b` â Ñлой коÑоÑÑм бÑл ÑÑиÑан Ñайл и коÑоÑÑм он бÑÐ´ÐµÑ Ð·Ð°Ð¿Ð¸Ñан.
РпÑимеÑе ниже Ñайл "replace.ex" ÑÑиÑÑваеÑÑÑ Ñлоем `:utf8`, а запиÑÑваеÑÑÑ Ñлоем `:raw` в ÑÑнкÑии `replace`:
```perl
local $_ = "replace.ex";
lay "abc";
replace { $b = ":utf8"; y/a/¡/ } [$_, ":raw"];
cat # => ¡bc
```
### See also
* [File::Edit](https://metacpan.org/pod/File::Edit) â `File::Edit->new($file)->replace('x', 'y')->save`.
* [File::Edit::Portable](https://metacpan.org/pod/File::Edit::Portable) â `File::Edit::Portable->new->splice(file => $file, line => 10, contens => ["line1", "line2"])`.
* [File::Replace](https://metacpan.org/pod/File::Replace) â `($infh,$outfh,$repl) = replace3($file); while (<$infh>) { print $outfh "X: $_" } $repl->finish`.
* [File::Replace::Inplace](https://metacpan.org/pod/File::Replace::Inplace).
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` не Ñказан â иÑполÑзÑÐµÑ `$_`.
```perl
local $_ = "catonce.txt";
lay "result";
catonce # -> "result"
catonce # -> undef
eval { catonce[] }; $@ # ~> catonce not use ref path!
```
lib/Aion/Fs.md view on Meta::CPAN
[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
cat "hello/big/world.txt" # => hello/big/world.txt :utf8 Hellow!
cat "hello/small/world.txt" # => noenter
[find "hello", "*.txt"] # --> [qw! hello/moon.txt hello/world.txt hello/big/world.txt hello/small/world.txt !]
[find "hello", "-d"] # --> [qw! hello hello/big hello/small !]
erase reverse find "hello";
-e "hello" # -> undef
```
lib/Aion/Fs.md view on Meta::CPAN
# SUBROUTINES/METHODS
## cat ($file)
СÑиÑÑÐ²Ð°ÐµÑ Ñайл. ÐÑли паÑамеÑÑ Ð½Ðµ Ñказан, иÑполÑзÑÐµÑ `$_`.
```perl
cat "/etc/passwd" # ~> root
```
`cat` ÑиÑÐ°ÐµÑ Ñо Ñлоем `:utf8`. Ðо можно ÑказаÑÑ Ð´ÑÑгой Ñлой ÑледÑÑÑим обÑазом:
```perl
lay "unicode.txt", "â¯";
length cat "unicode.txt" # -> 1
length cat["unicode.txt", ":raw"] # -> 3
```
`cat` вÑзÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑение в ÑлÑÑае оÑибки опеÑаÑии ввода-вÑвода:
```perl
lib/Aion/Fs.md view on Meta::CPAN
* [File::Util](https://metacpan.org/pod/File::Util) â `File::Util->new->load_file(file => 'file.txt')`.
* [IO::All](https://metacpan.org/pod/IO::All) â `io('file.txt') > $contents`.
* [IO::Util](https://metacpan.org/pod/IO::Util) â `$contents = ${ slurp 'file.txt' }`.
* [Mojo::File](https://metacpan.org/pod/Mojo::File) â `path($file)->slurp`.
## lay ($file?, $content)
ÐапиÑÑÐ²Ð°ÐµÑ `$content` в `$file`.
* ÐÑли Ñказан один паÑамеÑÑ, иÑполÑзÑÐµÑ `$_` вмеÑÑо `$file`.
* `lay`, иÑполÑзÑÐµÑ Ñлой `:utf8`. ÐÐ»Ñ ÑÐºÐ°Ð·Ð°Ð½Ð¸Ñ Ð¸Ð½Ð¾Ð³Ð¾ ÑÐ»Ð¾Ñ Ð¸ÑполÑзÑеÑÑÑ Ð¼Ð°ÑÑив из двÑÑ
ÑлеменÑов в паÑамеÑÑе `$file`:
```perl
lay "unicode.txt", "â¯" # => unicode.txt
lay ["unicode.txt", ":raw"], "â¯" # => unicode.txt
eval { lay "/", "â¯" }; $@ # ~> lay /: Is a directory
```
### See also
lib/Aion/Fs.md view on Meta::CPAN
find "ex", sub { find_stop if ++$count == 3; 1} # -> 2
```
### 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)`.
lib/Aion/Fs.md view on Meta::CPAN
* `unlink` + `rmdir`.
* [File::Path](https://metacpan.org/pod/File::Path) â `remove_tree("dir")`.
* [File::Path::Tiny](https://metacpan.org/pod/File::Path::Tiny) â `File::Path::Tiny::rm($path)`. Ðе вÑбÑаÑÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑений.
* [Mojo::File](https://metacpan.org/pod/Mojo::File) â `path($file)->remove`.
## replace (&sub, @files)
ÐаменÑÐµÑ ÐºÐ°Ð¶Ð´Ñй Ñайл на `$_`, еÑли его изменÑÐµÑ `&sub`. ÐозвÑаÑÐ°ÐµÑ ÑайлÑ, в коÑоÑÑÑ
не бÑло замен.
`@files` Ð¼Ð¾Ð¶ÐµÑ ÑодеÑжаÑÑ Ð¼Ð°ÑÑÐ¸Ð²Ñ Ð¸Ð· двÑÑ
ÑлеменÑов. ÐеÑвÑй ÑаÑÑмаÑÑиваеÑÑÑ ÐºÐ°Ðº пÑÑÑ, а вÑоÑой â как Ñлой. Слой по ÑмолÑÐ°Ð½Ð¸Ñ â `:utf8`.
`&sub` вÑзÑваеÑÑÑ Ð´Ð»Ñ ÐºÐ°Ð¶Ð´Ð¾Ð³Ð¾ Ñайла из `@files`. Ð Ð½ÐµÑ Ð¿ÐµÑедаÑÑÑÑ:
* `$_` â ÑодеÑжимое Ñайла.
* `$a` â пÑÑÑ Ðº ÑайлÑ.
* `$b` â Ñлой коÑоÑÑм бÑл ÑÑиÑан Ñайл и коÑоÑÑм он бÑÐ´ÐµÑ Ð·Ð°Ð¿Ð¸Ñан.
РпÑимеÑе ниже Ñайл "replace.ex" ÑÑиÑÑваеÑÑÑ Ñлоем `:utf8`, а запиÑÑваеÑÑÑ Ñлоем `:raw` в ÑÑнкÑии `replace`:
```perl
local $_ = "replace.ex";
lay "abc";
replace { $b = ":utf8"; y/a/¡/ } [$_, ":raw"];
cat # => ¡bc
```
### See also
* [File::Edit](https://metacpan.org/pod/File::Edit) â `File::Edit->new($file)->replace('x', 'y')->save`.
* [File::Edit::Portable](https://metacpan.org/pod/File::Edit::Portable) â `File::Edit::Portable->new->splice(file => $file, line => 10, contens => ["line1", "line2"])`.
* [File::Replace](https://metacpan.org/pod/File::Replace) â `($infh,$outfh,$repl) = replace3($file); while (<$infh>) { print $outfh "X: $_" } $repl->finish`.
* [File::Replace::Inplace](https://metacpan.org/pod/File::Replace::Inplace).
lib/Aion/Fs.md view on Meta::CPAN
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` не Ñказан â иÑполÑзÑÐµÑ `$_`.
```perl
local $_ = "catonce.txt";
lay "result";
catonce # -> "result"
catonce # -> undef
eval { catonce[] }; $@ # ~> catonce not use ref path!
```
lib/Aion/Fs.pm view on Meta::CPAN
mkdir $cat, $permission or ($! != FILE_EXISTS? die "mkpath $cat: $!": ());
}
}
$path
}
# СÑиÑÑÐ²Ð°ÐµÑ Ñайл
sub cat(;$) {
my ($file) = @_ == 0? $_: @_;
my $layer = ":utf8";
($file, $layer) = @$file if ref $file;
open my $f, "<$layer", $file or die "cat $file: $!";
read $f, my $x, -s $f;
close $f;
$x
}
# запиÑаÑÑ Ñайл
sub lay ($;$) {
my ($file, $s) = @_ == 1? ($_, @_): @_;
my $layer = ":utf8";
($file, $layer) = @$file if ref $file;
open my $f, ">$layer", $file or die "lay $file: $!";
local $\;
print $f $s;
close $f;
$file
}
# ÑÑиÑаÑÑ Ñайл, еÑли он еÑÑ Ð½Ðµ бÑл ÑÑиÑан
our %FILE_INC;
lib/Aion/Fs.pm view on Meta::CPAN
sub find_stop() {
die bless {}, "Aion::Fs::stop"
}
# ÐÑÐ¾Ð¸Ð·Ð²Ð¾Ð´Ð¸Ñ Ð·Ð°Ð¼ÐµÐ½Ñ Ð²Ð¾ вÑеÑ
ÑказаннÑÑ
ÑайлаÑ
. ÐозвÑаÑÐ°ÐµÑ ÑÐ°Ð¹Ð»Ñ Ð² коÑоÑÑÑ
замен не бÑло
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];
$fn->();
if($file ne $_) { lay [$$aref, $$bref], $_ } else { push @noreplace, $$aref if defined wantarray }
}
@noreplace
}
# СÑиÑÐ°ÐµÑ Ð²Ñе ÑказаннÑе ÑайлÑ. ÐозвÑаÑÐ°ÐµÑ Ð¿ÐµÑеданнÑе ÑайлÑ
sub erase(@) {
-d? rmdir: unlink or die "erase ${\(-d? 'dir': 'file')} $_: $!" for @_;
lib/Aion/Fs.pm view on Meta::CPAN
[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
cat "hello/big/world.txt" # => hello/big/world.txt :utf8 Hellow!
cat "hello/small/world.txt" # => noenter
[find "hello", "*.txt"] # --> [qw! hello/moon.txt hello/world.txt hello/big/world.txt hello/small/world.txt !]
[find "hello", "-d"] # --> [qw! hello hello/big hello/small !]
erase reverse find "hello";
-e "hello" # -> undef
=head1 DESCRIPTION
lib/Aion/Fs.pm view on Meta::CPAN
=back
=head1 SUBROUTINES/METHODS
=head2 cat ($file)
СÑиÑÑÐ²Ð°ÐµÑ Ñайл. ÐÑли паÑамеÑÑ Ð½Ðµ Ñказан, иÑполÑзÑÐµÑ C<$_>.
cat "/etc/passwd" # ~> root
C<cat> ÑиÑÐ°ÐµÑ Ñо Ñлоем C<:utf8>. Ðо можно ÑказаÑÑ Ð´ÑÑгой Ñлой ÑледÑÑÑим обÑазом:
lay "unicode.txt", "â¯";
length cat "unicode.txt" # -> 1
length cat["unicode.txt", ":raw"] # -> 3
C<cat> вÑзÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑение в ÑлÑÑае оÑибки опеÑаÑии ввода-вÑвода:
eval { cat "A" }; $@ # ~> cat A: No such file or directory
=head3 See also
lib/Aion/Fs.pm view on Meta::CPAN
=back
=head2 lay ($file?, $content)
ÐапиÑÑÐ²Ð°ÐµÑ C<$content> в C<$file>.
=over
=item * ÐÑли Ñказан один паÑамеÑÑ, иÑполÑзÑÐµÑ C<$_> вмеÑÑо C<$file>.
=item * C<lay>, иÑполÑзÑÐµÑ Ñлой C<:utf8>. ÐÐ»Ñ ÑÐºÐ°Ð·Ð°Ð½Ð¸Ñ Ð¸Ð½Ð¾Ð³Ð¾ ÑÐ»Ð¾Ñ Ð¸ÑполÑзÑеÑÑÑ Ð¼Ð°ÑÑив из двÑÑ
ÑлеменÑов в паÑамеÑÑе C<$file>:
=back
lay "unicode.txt", "â¯" # => unicode.txt
lay ["unicode.txt", ":raw"], "â¯" # => unicode.txt
eval { lay "/", "â¯" }; $@ # ~> lay /: Is a directory
=head3 See also
lib/Aion/Fs.pm view on Meta::CPAN
=item * L<AudioFile::Find> â иÑÐµÑ Ð°ÑдиоÑÐ°Ð¹Ð»Ñ Ð² Ñказанной диÑекÑоÑии. ÐозволÑÐµÑ ÑилÑÑÑоваÑÑ Ð¸Ñ
по аÑÑибÑÑам: названиÑ, аÑÑиÑÑÑ, жанÑÑ, алÑÐ±Ð¾Ð¼Ñ Ð¸ ÑÑÑкÑ...
=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> â как L<File::Find>, ÑолÑко пÑÑи Ñайлов в I<utf8>.
=item * L<File::Find::Age> â ÑоÑÑиÑÑÐµÑ ÑÐ°Ð¹Ð»Ñ Ð¿Ð¾ вÑемени модиÑикаÑии (наÑледÑÐµÑ 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> â Ð¸Ð¼ÐµÐµÑ ÐÐРинÑеÑÑÐµÐ¹Ñ Ñ Ð¸ÑеÑаÑоÑом и ÑÑнкÑии C<imap> и C<igrep>.
=item * L<File::Find::Match> â вÑзÑÐ²Ð°ÐµÑ Ð¾Ð±ÑабоÑÑик на каждÑй подоÑедÑий ÑилÑÑÑ. ÐоÑ
ож на C<switch>.
=item * L<File::Find::Node> â обÑ
Ð¾Ð´Ð¸Ñ Ð¸ÐµÑаÑÑ
Ð¸Ñ Ñайлов паÑаллелÑно неÑколÑкими пÑоÑеÑÑами: C<< tie @paths, IPC::Shareable, { key =E<gt> "GLUE STRING", create =E<gt> 1 }; File::Find::Node-E<gt>new(...
lib/Aion/Fs.pm view on Meta::CPAN
=item * L<File::Path::Tiny> â C<File::Path::Tiny::rm($path)>. Ðе вÑбÑаÑÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑений.
=item * L<Mojo::File> â C<< path($file)-E<gt>remove >>.
=back
=head2 replace (&sub, @files)
ÐаменÑÐµÑ ÐºÐ°Ð¶Ð´Ñй Ñайл на C<$_>, еÑли его изменÑÐµÑ C<&sub>. ÐозвÑаÑÐ°ÐµÑ ÑайлÑ, в коÑоÑÑÑ
не бÑло замен.
C<@files> Ð¼Ð¾Ð¶ÐµÑ ÑодеÑжаÑÑ Ð¼Ð°ÑÑÐ¸Ð²Ñ Ð¸Ð· двÑÑ
ÑлеменÑов. ÐеÑвÑй ÑаÑÑмаÑÑиваеÑÑÑ ÐºÐ°Ðº пÑÑÑ, а вÑоÑой â как Ñлой. Слой по ÑмолÑÐ°Ð½Ð¸Ñ â C<:utf8>.
C<&sub> вÑзÑваеÑÑÑ Ð´Ð»Ñ ÐºÐ°Ð¶Ð´Ð¾Ð³Ð¾ Ñайла из C<@files>. Ð Ð½ÐµÑ Ð¿ÐµÑедаÑÑÑÑ:
=over
=item * C<$_> â ÑодеÑжимое Ñайла.
=item * C<$a> â пÑÑÑ Ðº ÑайлÑ.
=item * C<$b> â Ñлой коÑоÑÑм бÑл ÑÑиÑан Ñайл и коÑоÑÑм он бÑÐ´ÐµÑ Ð·Ð°Ð¿Ð¸Ñан.
=back
РпÑимеÑе ниже Ñайл "replace.ex" ÑÑиÑÑваеÑÑÑ Ñлоем C<:utf8>, а запиÑÑваеÑÑÑ Ñлоем C<:raw> в ÑÑнкÑии C<replace>:
local $_ = "replace.ex";
lay "abc";
replace { $b = ":utf8"; y/a/¡/ } [$_, ":raw"];
cat # => ¡bc
=head3 See also
=over
=item * L<File::Edit> â C<< File::Edit-E<gt>new($file)-E<gt>replace('x', 'y')-E<gt>save >>.
=item * L<File::Edit::Portable> â C<< File::Edit::Portable-E<gt>new-E<gt>splice(file =E<gt> $file, line =E<gt> 10, contens =E<gt> ["line1", "line2"]) >>.
lib/Aion/Fs.pm view on Meta::CPAN
include("A")->new # ~> A=HASH\(0x\w+\)
[map include, qw/A N/] # --> [qw/A N/]
{ local $_="N"; include->ex } # -> 123
=head2 catonce (;$file)
СÑиÑÑÐ²Ð°ÐµÑ Ñайл в пеÑвÑй Ñаз. ÐÑÐ±Ð°Ñ Ð¿Ð¾ÑледÑÑÑÐ°Ñ Ð¿Ð¾Ð¿ÑÑка ÑÑиÑаÑÑ ÑÑÐ¾Ñ Ñайл возвÑаÑÐ°ÐµÑ C<undef>. ÐÑполÑзÑеÑÑÑ Ð´Ð»Ñ Ð²ÑÑавки модÑлей js и css в ÑезÑл...
=over
=item * C<$file> Ð¼Ð¾Ð¶ÐµÑ ÑодеÑжаÑÑ Ð¼Ð°ÑÑÐ¸Ð²Ñ Ð¸Ð· двÑÑ
ÑлеменÑов. ÐеÑвÑй ÑаÑÑмаÑÑиваеÑÑÑ ÐºÐ°Ðº пÑÑÑ, а вÑоÑой â как Ñлой. Слой по ÑмолÑÐ°Ð½Ð¸Ñ â C<:utf8>.
=item * ÐÑли C<$file> не Ñказан â иÑполÑзÑÐµÑ C<$_>.
=back
local $_ = "catonce.txt";
lay "result";
catonce # -> "result"
catonce # -> undef
t/aion/fs.t view on Meta::CPAN
use common::sense; use open qw/:std :utf8/; use Carp qw//; use File::Basename qw//; use File::Find qw//; use File::Slurper qw//; use File::Spec qw//; use File::Path qw//; use Scalar::Util qw//; use Test::More 0.98; BEGIN { $SIG{__DIE__} = sub ...
# # NAME
#
# Aion::Fs - ÑÑилиÑÑ Ð´Ð»Ñ Ñайловой ÑиÑÑемÑ: ÑÑение, запиÑÑ, поиÑк, замена Ñайлов и Ñ.д.
#
# # VERSION
#
# 0.1.0
#
# # SYNOPSIS
#
t/aion/fs.t view on Meta::CPAN
::is_deeply scalar do {[map cat, grep -f, find ["hello/big", "hello/small"]]}, scalar do {[qw/ hellow! noenter /]}, '[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 $_: $!" };
::is_deeply scalar do {\@noreplaced}, scalar do {["hello/moon.txt"]}, '\@noreplaced # --> ["hello/moon.txt"]';
::is scalar do {cat "hello/world.txt"}, "hello/world.txt :utf8 Hi!", 'cat "hello/world.txt" # => hello/world.txt :utf8 Hi!';
::is scalar do {cat "hello/moon.txt"}, "noreplace", 'cat "hello/moon.txt" # => noreplace';
::is scalar do {cat "hello/big/world.txt"}, "hello/big/world.txt :utf8 Hellow!", 'cat "hello/big/world.txt" # => hello/big/world.txt :utf8 Hellow!';
::is scalar do {cat "hello/small/world.txt"}, "noenter", 'cat "hello/small/world.txt" # => noenter';
::is_deeply scalar do {[find "hello", "*.txt"]}, scalar do {[qw! hello/moon.txt hello/world.txt hello/big/world.txt hello/small/world.txt !]}, '[find "hello", "*.txt"] # --> [qw! hello/moon.txt hello/world.txt hello/big/world.txt hello/smal...
::is_deeply scalar do {[find "hello", "-d"]}, scalar do {[qw! hello hello/big hello/small !]}, '[find "hello", "-d"] # --> [qw! hello hello/big hello/small !]';
erase reverse find "hello";
::is scalar do {-e "hello"}, scalar do{undef}, '-e "hello" # -> undef';
#
t/aion/fs.t view on Meta::CPAN
# # SUBROUTINES/METHODS
#
# ## cat ($file)
#
# СÑиÑÑÐ²Ð°ÐµÑ Ñайл. ÐÑли паÑамеÑÑ Ð½Ðµ Ñказан, иÑполÑзÑÐµÑ `$_`.
#
done_testing; }; subtest 'cat ($file)' => sub {
::like scalar do {cat "/etc/passwd"}, qr!root!, 'cat "/etc/passwd" # ~> root';
#
# `cat` ÑиÑÐ°ÐµÑ Ñо Ñлоем `:utf8`. Ðо можно ÑказаÑÑ Ð´ÑÑгой Ñлой ÑледÑÑÑим обÑазом:
#
lay "unicode.txt", "â¯";
::is scalar do {length cat "unicode.txt"}, scalar do{1}, 'length cat "unicode.txt" # -> 1';
::is scalar do {length cat["unicode.txt", ":raw"]}, scalar do{3}, 'length cat["unicode.txt", ":raw"] # -> 3';
#
# `cat` вÑзÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑение в ÑлÑÑае оÑибки опеÑаÑии ввода-вÑвода:
#
t/aion/fs.t view on Meta::CPAN
# * [File::Util](https://metacpan.org/pod/File::Util) â `File::Util->new->load_file(file => 'file.txt')`.
# * [IO::All](https://metacpan.org/pod/IO::All) â `io('file.txt') > $contents`.
# * [IO::Util](https://metacpan.org/pod/IO::Util) â `$contents = ${ slurp 'file.txt' }`.
# * [Mojo::File](https://metacpan.org/pod/Mojo::File) â `path($file)->slurp`.
#
# ## lay ($file?, $content)
#
# ÐапиÑÑÐ²Ð°ÐµÑ `$content` в `$file`.
#
# * ÐÑли Ñказан один паÑамеÑÑ, иÑполÑзÑÐµÑ `$_` вмеÑÑо `$file`.
# * `lay`, иÑполÑзÑÐµÑ Ñлой `:utf8`. ÐÐ»Ñ ÑÐºÐ°Ð·Ð°Ð½Ð¸Ñ Ð¸Ð½Ð¾Ð³Ð¾ ÑÐ»Ð¾Ñ Ð¸ÑполÑзÑеÑÑÑ Ð¼Ð°ÑÑив из двÑÑ
ÑлеменÑов в паÑамеÑÑе `$file`:
#
done_testing; }; subtest 'lay ($file?, $content)' => sub {
::is scalar do {lay "unicode.txt", "â¯"}, "unicode.txt", 'lay "unicode.txt", "â¯" # => unicode.txt';
::is scalar do {lay ["unicode.txt", ":raw"], "â¯"}, "unicode.txt", 'lay ["unicode.txt", ":raw"], "â¯" # => unicode.txt';
::like scalar do {eval { lay "/", "â¯" }; $@}, qr!lay /: Is a directory!, 'eval { lay "/", "â¯" }; $@ # ~> lay /: Is a directory';
#
# ### See also
#
t/aion/fs.t view on Meta::CPAN
::is scalar do {find "ex", sub { find_stop if ++$count == 3; 1}}, scalar do{2}, 'find "ex", sub { find_stop if ++$count == 3; 1} # -> 2';
#
# ### 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)`.
t/aion/fs.t view on Meta::CPAN
#
# * `unlink` + `rmdir`.
# * [File::Path](https://metacpan.org/pod/File::Path) â `remove_tree("dir")`.
# * [File::Path::Tiny](https://metacpan.org/pod/File::Path::Tiny) â `File::Path::Tiny::rm($path)`. Ðе вÑбÑаÑÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑений.
# * [Mojo::File](https://metacpan.org/pod/Mojo::File) â `path($file)->remove`.
#
# ## replace (&sub, @files)
#
# ÐаменÑÐµÑ ÐºÐ°Ð¶Ð´Ñй Ñайл на `$_`, еÑли его изменÑÐµÑ `&sub`. ÐозвÑаÑÐ°ÐµÑ ÑайлÑ, в коÑоÑÑÑ
не бÑло замен.
#
# `@files` Ð¼Ð¾Ð¶ÐµÑ ÑодеÑжаÑÑ Ð¼Ð°ÑÑÐ¸Ð²Ñ Ð¸Ð· двÑÑ
ÑлеменÑов. ÐеÑвÑй ÑаÑÑмаÑÑиваеÑÑÑ ÐºÐ°Ðº пÑÑÑ, а вÑоÑой â как Ñлой. Слой по ÑмолÑÐ°Ð½Ð¸Ñ â `:utf8`.
#
# `&sub` вÑзÑваеÑÑÑ Ð´Ð»Ñ ÐºÐ°Ð¶Ð´Ð¾Ð³Ð¾ Ñайла из `@files`. Ð Ð½ÐµÑ Ð¿ÐµÑедаÑÑÑÑ:
#
# * `$_` â ÑодеÑжимое Ñайла.
# * `$a` â пÑÑÑ Ðº ÑайлÑ.
# * `$b` â Ñлой коÑоÑÑм бÑл ÑÑиÑан Ñайл и коÑоÑÑм он бÑÐ´ÐµÑ Ð·Ð°Ð¿Ð¸Ñан.
#
# РпÑимеÑе ниже Ñайл "replace.ex" ÑÑиÑÑваеÑÑÑ Ñлоем `:utf8`, а запиÑÑваеÑÑÑ Ñлоем `:raw` в ÑÑнкÑии `replace`:
#
done_testing; }; subtest 'replace (&sub, @files)' => sub {
local $_ = "replace.ex";
lay "abc";
replace { $b = ":utf8"; y/a/¡/ } [$_, ":raw"];
::is scalar do {cat}, "¡bc", 'cat # => ¡bc';
#
# ### See also
#
# * [File::Edit](https://metacpan.org/pod/File::Edit) â `File::Edit->new($file)->replace('x', 'y')->save`.
# * [File::Edit::Portable](https://metacpan.org/pod/File::Edit::Portable) â `File::Edit::Portable->new->splice(file => $file, line => 10, contens => ["line1", "line2"])`.
# * [File::Replace](https://metacpan.org/pod/File::Replace) â `($infh,$outfh,$repl) = replace3($file); while (<$infh>) { print $outfh "X: $_" } $repl->finish`.
# * [File::Replace::Inplace](https://metacpan.org/pod/File::Replace::Inplace).
#
t/aion/fs.t view on Meta::CPAN
use lib "lib";
::like scalar do {include("A")->new}, qr!A=HASH\(0x\w+\)!, 'include("A")->new # ~> A=HASH\(0x\w+\)';
::is_deeply scalar do {[map include, qw/A N/]}, scalar do {[qw/A N/]}, '[map include, qw/A N/] # --> [qw/A N/]';
::is scalar do {{ local $_="N"; include->ex }}, scalar do{123}, '{ local $_="N"; include->ex } # -> 123';
#
# ## catonce (;$file)
#
# СÑиÑÑÐ²Ð°ÐµÑ Ñайл в пеÑвÑй Ñаз. ÐÑÐ±Ð°Ñ Ð¿Ð¾ÑледÑÑÑÐ°Ñ Ð¿Ð¾Ð¿ÑÑка ÑÑиÑаÑÑ ÑÑÐ¾Ñ Ñайл возвÑаÑÐ°ÐµÑ `undef`. ÐÑполÑзÑеÑÑÑ Ð´Ð»Ñ Ð²ÑÑавки модÑлей js и css в ÑезÑÐ...
#
# * `$file` Ð¼Ð¾Ð¶ÐµÑ ÑодеÑжаÑÑ Ð¼Ð°ÑÑÐ¸Ð²Ñ Ð¸Ð· двÑÑ
ÑлеменÑов. ÐеÑвÑй ÑаÑÑмаÑÑиваеÑÑÑ ÐºÐ°Ðº пÑÑÑ, а вÑоÑой â как Ñлой. Слой по ÑмолÑÐ°Ð½Ð¸Ñ â `:utf8`.
# * ÐÑли `$file` не Ñказан â иÑполÑзÑÐµÑ `$_`.
#
done_testing; }; subtest 'catonce (;$file)' => sub {
local $_ = "catonce.txt";
lay "result";
::is scalar do {catonce}, scalar do{"result"}, 'catonce # -> "result"';
::is scalar do {catonce}, scalar do{undef}, 'catonce # -> undef';
::like scalar do {eval { catonce[] }; $@}, qr!catonce not use ref path\!!, 'eval { catonce[] }; $@ # ~> catonce not use ref path!';