Loading ...
Sorry, an error occurred while loading the content.

Re: Equivalent function to shell basename?

Expand Messages
  • Rich
    ... basename ... tried ... perldoc ... fileparse( /virgil/aeneid/draft.book7 , ... Tom, I just tried perldoc File::Basename and got the man pages! Thanks!
    Message 1 of 2 , Dec 8, 2000
    • 0 Attachment
      --- In perl-beginner@egroups.com, Tom Barron <tbarron@m...> wrote:
      > Steve Milo wrote:
      > > ...
      > > use File::Basename;
      > >
      > > $basename = basename(0);
      > >
      > > >From what I remember there are a few fields that come up when
      basename
      > > is used. 'basename(0)' refers to the name of the program that
      > > 'executed' basename.
      > >
      > > I havent used it for a while so I cant provide more details, I
      tried
      > > perldoc -f basename on my system but it doesnt come up. Probably
      > > something wrong here.
      >
      > 'perldoc File::Basename' works for me. I think you have to give
      perldoc
      > the whole name, including '::' and in the correct case.
      >
      > From 'perldoc File::Basename':
      >
      > Using UNIX file syntax:
      >
      > ($base,$path,$type) =
      fileparse('/virgil/aeneid/draft.book7',
      > '\.book\d+');
      >
      > would yield
      >
      > $base eq 'draft'
      > $path eq '/virgil/aeneid/',
      > $type eq '.book7'
      >
      > ....
      >
      > basename
      > The basename() routine returns the first element of
      > the list produced by calling fileparse() with the
      > same arguments, except that it always quotes
      > metacharacters in the given suffixes. It is provided
      > for programmer compatibility with the UNIX shell
      > command basename(1).
      >
      >
      > --
      > Tom

      Tom,
      I just tried 'perldoc File::Basename' and got the man pages! Thanks!
      Rich
    Your message has been successfully submitted and would be delivered to recipients shortly.