=begin metadata

Name: basename
Description: print the basename of a file
Author: Abigail, perlpowertools@abigail.be
License: perl

=end metadata


use strict;
use File::Basename;

my ($VERSION) = '1.2';

unless (@ARGV == 1 || @ARGV == 2) {
    $0 = basename ($0);
    print <<EOF;
$0 (Perl bin utils) $VERSION
$0 string [suffix | /pattern/]

if (@ARGV == 2) {
    $ARGV [1] = quotemeta $ARGV [1] unless $ARGV [1] =~ s{^/(.*)/$}{$1};

print +(fileparse @ARGV) [0], "\n";



=head1 NAME

basename - print the basename of a file


basename string [suffix | /pattern/]


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.


The working of I<basename> is not influenced by any environment variables.

=head1 BUGS

I<basename> has no known bugs.


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 AUTHOR

The Perl implementation of I<basename> was written by Abigail,


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.