Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Knob Re: Parse out the extension of a filename - return base of filename.

by knobunc (Pilgrim)
on Mar 13, 2002 at 14:43 UTC ( [id://151386]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Parse out the extension of a filename - return base of filename.
in thread Parse out the extension of a filename - return base of filename.

Umm.. try running the example he gave (or reading the node more closely). It does match the last part of the filename following the final dot. So if you run:

perl -MFile::Basename -e 'print join ":", fileparse("foo.bar.baz", "\\ +.[^.]+"), "\n"'

It produces foo.bar as the filename, ./ as the directory and baz as the extension. A few more filenames and results follow:

Input filenameBase nameExtension
foo.bar.bazfoo.barbaz
foo.bar foo bar
foo foo none

-ben

  • Comment on Knob Re: Parse out the extension of a filename - return base of filename.
  • Download Code

Replies are listed 'Best First'.
Re: Knob Re: Parse out the extension of a filename - return base of filename.
by snafu (Chaplain) on Mar 13, 2002 at 14:47 UTC
    Yup. I know. Clearly I spoke before I tested and I did a terrible terrible thing and assumed his code wouldn't work. But, alas, I was wrong. :)

    _ _ _ _ _ _ _ _ _ _
    - Jim
    Insert clever comment here...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://151386]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-16 14:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found