dirname.pl 268 B

123456789101112131415161718
  1. #!/usr/local/bin/perl
  2. if ($#ARGV < 0) {
  3. die "dirname.pl: too few arguments\n";
  4. } elsif ($#ARGV > 0) {
  5. die "dirname.pl: too many arguments\n";
  6. }
  7. my $d = $ARGV[0];
  8. if ($d =~ m|.*/.*|) {
  9. $d =~ s|/[^/]*$||;
  10. } else {
  11. $d = ".";
  12. }
  13. print $d,"\n";
  14. exit(0);