Aion-Fs
view release on metacpan or search on metacpan
СÑиÑÑÐ²Ð°ÐµÑ Ñайл. ÐÑли паÑамеÑÑ Ð½Ðµ Ñказан, иÑполÑзÑÐµÑ `$_`.
```perl
cat "/etc/passwd" # ~> root
```
`cat` ÑиÑÐ°ÐµÑ Ñо Ñлоем `:utf8`. Ðо можно ÑказаÑÑ Ð´ÑÑгой Ñлой ÑледÑÑÑим обÑазом:
```perl
lay "unicode.txt", "â¯";
length cat "unicode.txt" # -> 1
length cat["unicode.txt", ":raw"] # -> 3
```
`cat` вÑзÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑение в ÑлÑÑае оÑибки опеÑаÑии ввода-вÑвода:
```perl
eval { cat "A" }; $@ # ~> cat A: No such file or directory
```
### See also
* [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
* [autodie](https://metacpan.org/pod/autodie) â `open $f, ">r.txt"; print $f $contents; close $f`.
* [File::Slurp](https://metacpan.org/pod/File::Slurp) â `write_file('file.txt', $contents)`.
* [File::Slurper](https://metacpan.org/pod/File::Slurper) â `write_text('file.txt', $contents)`, `write_binary('file.txt', $contents)`.
* [IO::All](https://metacpan.org/pod/IO::All) â `io('file.txt') < $contents`.
lib/Aion/Fs.md view on Meta::CPAN
СÑиÑÑÐ²Ð°ÐµÑ Ñайл. ÐÑли паÑамеÑÑ Ð½Ðµ Ñказан, иÑполÑзÑÐµÑ `$_`.
```perl
cat "/etc/passwd" # ~> root
```
`cat` ÑиÑÐ°ÐµÑ Ñо Ñлоем `:utf8`. Ðо можно ÑказаÑÑ Ð´ÑÑгой Ñлой ÑледÑÑÑим обÑазом:
```perl
lay "unicode.txt", "â¯";
length cat "unicode.txt" # -> 1
length cat["unicode.txt", ":raw"] # -> 3
```
`cat` вÑзÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑение в ÑлÑÑае оÑибки опеÑаÑии ввода-вÑвода:
```perl
eval { cat "A" }; $@ # ~> cat A: No such file or directory
```
### See also
lib/Aion/Fs.md view on Meta::CPAN
* [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
* [autodie](https://metacpan.org/pod/autodie) â `open $f, ">r.txt"; print $f $contents; close $f`.
* [File::Slurp](https://metacpan.org/pod/File::Slurp) â `write_file('file.txt', $contents)`.
* [File::Slurper](https://metacpan.org/pod/File::Slurper) â `write_text('file.txt', $contents)`, `write_binary('file.txt', $contents)`.
* [IO::All](https://metacpan.org/pod/IO::All) â `io('file.txt') < $contents`.
lib/Aion/Fs.pm view on Meta::CPAN
=head1 SUBROUTINES/METHODS
=head2 cat ($file)
Reads the file. If no parameter is specified, use C<$_>.
cat "/etc/passwd" # ~> root
C<cat> reads with layer C<:utf8>. But you can specify another layer like this:
lay "unicode.txt", "â¯";
length cat "unicode.txt" # -> 1
length cat["unicode.txt", ":raw"] # -> 3
C<cat> throws an exception if the I/O operation fails:
eval { cat "A" }; $@ # ~> cat A: No such file or directory
=head3 See also
=over
=item * L<autodie> â C<< open $f, "r.txt"; $s = join "", E<lt>$fE<gt>; close $f >>.
lib/Aion/Fs.pm view on Meta::CPAN
Writes C<$content> to C<$file>.
=over
=item * If one parameter is specified, use C<$_> instead of C<$file>.
=item * C<lay>, uses the C<:utf8> layer. To specify a different layer, use an array of two elements in the C<$file> parameter:
=back
lay "unicode.txt", "â¯" # => unicode.txt
lay ["unicode.txt", ":raw"], "â¯" # => unicode.txt
eval { lay "/", "â¯" }; $@ # ~> lay /: Is a directory
=head3 See also
=over
=item * L<autodie> â C<< open $f, "E<gt>r.txt"; print $f $contents; close $f >>.
=item * L<File::Slurp> â C<write_file('file.txt', $contents)>.
t/aion/fs.t view on Meta::CPAN
#
# СÑиÑÑÐ²Ð°ÐµÑ Ñайл. ÐÑли паÑамеÑÑ Ð½Ðµ Ñказан, иÑполÑзÑÐµÑ `$_`.
#
::done_testing; }; subtest 'cat ($file)' => sub {
::like scalar do {cat "/etc/passwd"}, qr{root}, 'cat "/etc/passwd" # ~> root'; undef $::_g0; undef $::_e0;
#
# `cat` ÑиÑÐ°ÐµÑ Ñо Ñлоем `:utf8`. Ðо можно ÑказаÑÑ Ð´ÑÑгой Ñлой ÑледÑÑÑим обÑазом:
#
lay "unicode.txt", "â¯";
local ($::_g0 = do {length cat "unicode.txt"}, $::_e0 = do {1}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, 'length cat "unicode.txt" # -> 1' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {length cat["unicode.txt", ":raw"]}, $::_e0 = do {3}); ::ok defined($::_g0) == defined($::_e0) && $::_g0 eq $::_e0, 'length cat["unicode.txt", ":raw"] # -> 3' or ::diag ::_struct_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
#
# `cat` вÑзÑÐ²Ð°ÐµÑ Ð¸ÑклÑÑение в ÑлÑÑае оÑибки опеÑаÑии ввода-вÑвода:
#
::like scalar do {eval { cat "A" }; $@}, qr{cat A: No such file or directory}, 'eval { cat "A" }; $@ # ~> cat A: No such file or directory'; undef $::_g0; undef $::_e0;
#
# ### See also
#
t/aion/fs.t view on Meta::CPAN
# * [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 {
local ($::_g0 = do {lay "unicode.txt", "â¯"}, $::_e0 = "unicode.txt"); ::ok $::_g0 eq $::_e0, 'lay "unicode.txt", "â¯" # => unicode.txt' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
local ($::_g0 = do {lay ["unicode.txt", ":raw"], "â¯"}, $::_e0 = "unicode.txt"); ::ok $::_g0 eq $::_e0, 'lay ["unicode.txt", ":raw"], "â¯" # => unicode.txt' or ::diag ::_string_diff($::_g0, $::_e0); undef $::_g0; undef $::_e0;
::like scalar do {eval { lay "/", "â¯" }; $@}, qr{lay /: Is a directory}, 'eval { lay "/", "â¯" }; $@ # ~> lay /: Is a directory'; undef $::_g0; undef $::_e0;
#
# ### See also
#
# * [autodie](https://metacpan.org/pod/autodie) â `open $f, ">r.txt"; print $f $contents; close $f`.
# * [File::Slurp](https://metacpan.org/pod/File::Slurp) â `write_file('file.txt', $contents)`.
# * [File::Slurper](https://metacpan.org/pod/File::Slurper) â `write_text('file.txt', $contents)`, `write_binary('file.txt', $contents)`.
# * [IO::All](https://metacpan.org/pod/IO::All) â `io('file.txt') < $contents`.
( run in 0.933 second using v1.01-cache-2.11-cpan-f56aa216473 )