Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

by demerphq (Chancellor)
on Mar 27, 2002 at 09:55 UTC ( [id://154625]=note: print w/replies, xml ) Need Help??


in reply to Re: 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.

    According to everything I have read on PM, the use of rindex() and substr() is a poor way to do this task.

      What the...? Can anyone second that
To a certain degree I can second that. Using rindex and index can cause issues. Consider if you have directories with dots in em? Consider if you have multiple extensions, eg File.pl.bak. And for using rindex and index for other aspects of path parsing is also bad especially when you consider the the various path delimiters, and portability issues.

Actually it was the use of rindex that caused a script here to behave very strangely just the other day.

BTW, you and snafu might like to have a look at one of my earlier posts (and the thread its in) for some interesting discussion about parsing filenames/urls with a regex.

Yves / DeMerphq
---
Writing a good benchmark isnt as easy as it might look.

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-20 08:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found