Aion-Fs
view release on metacpan or search on metacpan
lib/Aion/Fs.pm view on Meta::CPAN
For a list of supported operating systems, see the examples of the C<path> subroutine just above or like this: C<keys %Aion::Fs::FS>.
OS names are case insensitive.
local $_ = ">x>y>z.doc.zip";
transpath "vos", "unix" # \> /x/y/z.doc.zip
transpath "vos", "VMS" # \> [.x.y]z.doc.zip
transpath $_, "vos", "RiscOS" # \> .x.y.z/doc/zip
=head2 splitdir (;$dir)
Splits a directory into components. The directory should first be obtained from C<< path-E<gt>{dir} >>.
local $^O = "unix";
[ splitdir "/x/" ] # --> ["", "x", ""]
=head2 joindir (;$dirparts)
Combines a directory from its components. The resulting directory should then be included in C<< path +{dir =E<gt> $dir} >>.
local $^O = "unix";
joindir qw/x y z/ # => x/y/z
path +{ dir => joindir qw/x y z/ } # => x/y/z/
=head2 splitext (;$ext)
Breaks the extension into its components. The extension should first be obtained from C<< path-E<gt>{ext} >>.
local $^O = "unix";
[ splitext ".x." ] # --> ["", "x", ""]
=head2 joinext (;$extparts)
Combines an extension from its components. The resulting extension should then be included in C<< path +{ext =E<gt> $ext} >>.
local $^O = "unix";
joinext qw/x y z/ # => x.y.z
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;
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>.
=item * If C<$file> is not specified, use C<$_>.
=back
local $_ = "catonce.txt";
lay "result";
catonce # -> "result"
catonce # -> undef
eval { catonce[] }; $@ # ~> catonce not use ref path!
=head2 wildcard (;$wildcard)
Converts a file mask to a regular expression. Without a parameter, uses C<$_>.
=over
=item * C<**> - C<[^/]*>
=item * C<*> - C<.*>
=item * C<?> - C<.>
=item * C<??> - C<[^/]>
=item * C<{> - C<(>
=item * C<}> - C<)>
=item * C<,> - C<|>
=item * Other characters are escaped using C<quotemeta>.
=back
wildcard "*.{pm,pl}" # \> (?^usn:^.*?\.(pm|pl)$)
wildcard "?_??_**" # \> (?^usn:^._[^/]_[^/]*?$)
Used in filters of the C<find> function.
=head3 See also
=over
=item * L<File::Wildcard>.
=item * L<String::Wildcard::Bash>.
( run in 0.845 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )