File-Tools

 view release on metacpan or  search on metacpan

lib/File/Tools.pm  view on Meta::CPAN

Given a path to a file or directory returns the last part of the path.

See L<File::Basename> for details.

=cut
sub basename {
  require File::Basename;
  File::Basename::basename(@_);
}

=head2 cat

Not implemented.

See L<slurp>

To process all the files on the command line and print them to the screen.

 while (my $line = <>) {
   print $line;
 }

In shell cut is usually used to concatenate two or more files. That can be achived
with the previous code redirecting it to a file using > command line redirector.

=cut
sub cat {
  _not_implemented();
}


=head2 catfile

Concatenating parts of a path in a platform independent way. See also L<File::Spec>

=cut
sub catfile {
  require File::Spec;
  File::Spec->catfile(@_);
}



=head2 cd

Use the built in chdir function.

=cut




=head2 chmod

Use the built in chmod function.

=cut



=head2 chown

For now use the built in chown function.

It accepts only UID and GID values, but it is easy to retreive them:

 chown $uid, $gid, @files;
 chown getpwnam($user), getgrname($group), @files;

For recursive application use the L<find> function.

 find( sub {chown $uid, $gid, $_}, @dirs);

Windows: See chmod above.

=cut


=head2 cmp

See C<compare>

=head2 compare

Compare two files
See L<File::Compare> for details.

=cut
sub compare {
    require File::Compare;
    File::Compare::compare(@_);
}


=head2 compress

Not implemented.

See some of the external modules

=cut




=head2 copy

Copy one file to another name.

For details see L<File::Copy>

For now this does not provide recourseive copy. Later we will provide that
too using either one of these modules: L<File::NCopy> or L<File::Copy::Recursive>.

=cut
sub copy {
  require File::Copy;
  File::Copy::copy(@_);
}


=head2 cut

Partially implemented but probably will be removed.

Returns some of the fields of a given string (or strings).
As a UNIX command it can work on every line on STDIN or in a list of files.
When implementing it in Perl the most difficult part is to parse the parameters
in order to account for all the overlapping possibilities which should actually
be considered as user error.

  cut -b 1 file



( run in 1.040 second using v1.01-cache-2.11-cpan-71847e10f99 )