#!/usr/local/bin/perl -w
#
# $Id: basename.abigail,v 1.3 2004/08/05 14:17:50 cwest Exp $
#
# $Log: basename.abigail,v $
# Revision 1.3 2004/08/05 14:17:50 cwest
# cleanup, new version number on website
#
# Revision 1.1 2004/07/23 20:10:00 cwest
# initial import
#
# Revision 1.1 1999/02/27 00:18:47 abigail
# Initial revision
#
#
use strict;
use File::Basename;
my ($VERSION) = '$Revision: 1.3 $' =~ /([.\d]+)/;
unless (@ARGV == 1 || @ARGV == 2) {
$0 = basename ($0);
print <<EOF;
$0 (Perl bin utils) $VERSION
$0 string [suffix | /pattern/]
EOF
exit;
};
if (@ARGV == 2) {
$ARGV [1] = quotemeta $ARGV [1] unless $ARGV [1] =~ s{^/(.*)/$}{$1};
}
print +(fileparse @ARGV) [0], "\n";
__END__
=pod
=head1 NAME
basename -- print the basename of a file.
=head1 SYNOPSIS
basename string [suffix | /pattern/]
=head1 DESCRIPTION
I<basename> prints the file component of a path. A second argument to
I<basename> is interpreted as a suffix to remove from the file. If the
suffix is sandwiched between slashes, the suffix is considered a
Perl regular expression, anything at the end of the string that matches
is removed before printing it out.
=head2 OPTIONS
I<basename> does not accept any options.
=head1 ENVIRONMENT
The working of I<basename> is not influenced by any environment variables.
=head1 BUGS
I<basename> has no known bugs.
=head1 STANDARDS
This I<basename> implementation is compliant with the B<IEEE Std1003.2-1992>
specification, also known as B<POSIX.2>.
This I<basename> implementation is compatible with the
B<OpenBSD> implementation.
The I</pattern/> is specific for this Perl implementation.
=head1 REVISION HISTORY
$Log: basename.abigail,v $
Revision 1.3 2004/08/05 14:17:50 cwest
cleanup, new version number on website
Revision 1.1 2004/07/23 20:10:00 cwest
initial import
Revision 1.1 1999/02/27 00:18:47 abigail
Initial revision
=head1 AUTHOR
The Perl implementation of I<basename> was written by Abigail,
I<abigail@fnx.com>.
=head1 COPYRIGHT and LICENSE
This program is copyright by Abigail 1999.
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