——#!/usr/bin/perl
=begin metadata
Name: dirname
Description: print the directory name of a path
Author: Michael Mikonos
Auhtor: Abigail, perlpowertools@abigail.be
License: perl
=end metadata
=cut
use
strict;
my
$Program
= basename($0);
our
$VERSION
=
'1.3'
;
getopts(
''
) or usage();
usage()
unless
scalar
(
@ARGV
) == 1;
my
$path
=
shift
;
my
$dir
= dirname(
$path
);
$dir
,
"\n"
;
exit
0;
sub
VERSION_MESSAGE {
"$Program version $VERSION\n"
;
exit
0;
}
sub
usage {
warn
"usage: $Program string\n"
;
exit
1;
}
__END__
=pod
=head1 NAME
dirname - print the directory name of a path
=head1 SYNOPSIS
dirname string
=head1 DESCRIPTION
I<dirname> prints the directory component of a path. Everything starting
from the last I</> (or whatever the path separator is on your OS) is
deleted.
=head2 OPTIONS
=over 4
=item * --version
=back
=head1 ENVIRONMENT
The working of I<dirname> is not influenced by any environment variables.
=head1 BUGS
I<dirname> has no known bugs.
=head1 STANDARDS
This I<dirname> implementation is compliant with the B<IEEE Std1003.2-1992>
specification, also known as B<POSIX.2>.
This I<dirname> implementation is compatible with the
B<OpenBSD> implementation.
=head1 AUTHOR
This implementation of I<dirname> was adapted by Michael Mikonos.
The original version was written by Abigail, but the code was completely replaced.
=head1 COPYRIGHT and LICENSE
This program is copyright by Abigail, 1999, and Michael Mikonos, 2024.
This program is free and open software. You may use, copy, modify, distribute
and sell this program (and any modified variants) in any way you wish,
provided you do not restrict others to do the same.
=cut