Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

by snafu (Chaplain)
on Mar 13, 2002 at 13:12 UTC ( [id://151367]=note: print w/replies, xml ) Need Help??


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

So far, your comments have been the most helpful for me understand:

where do you really want to die? :-)

Good catch! I should have caught this. I will rectify this asap.

Aside from this, I've always interpreted "base filename" and "extention" to be 2 particular and discrete things, so if you do have a file named foo.bar.baz.quux, you've got a base filename of "foo.bar.baz" and an extention of "quux";

My desire was to actually remove the extension from the filename base. I agree with you on the two distinct entities. I need to go back through my comments because I am not sure why you are making this statement. I must have said something somewhere that wasn't too clear :)

do you have a particular need or use to split on every dot, or were you being (lowercase) lazy?

Well, I was only solving this the way I thought it in my mind would be best to solve it. I wasn't trying to win a Nobel Peace Prize or anything =P. Perhaps I should have placed this snippet of code some place else on PM?

in any case, it really seems like you're doing too much work here

I admit, I am doing more work than you are doing :). Nice example. It never occurred to me to use reverse(). :(

Additionally, I would not use any module that required me to declare a DEBUG variable (or constant, in this case) in my own package, but perhaps this could be addressed if you make your File::Basename::foo package. File::Basename::foo::DEBUG would be ok with me.

If I did make a package out of this I wouldn't include the DEBUG stuff. At least not as a requirement. This is a snippet of code I was using in a script of mine that I actually though was a good piece of code (heh, I guess I was wrong). This snippet was written to work in my already existing script, therefore, there was superfluous stuff in it already that I did not take out. I was merely suggesting to anyone who wanted to use the snippet would either need to edit it slightly or use it as-is and simply create a global variable called DEBUG.

If I wrote this as a module, I would get rid of the DEBUG necessity altogether and simply do as you suggested with the File::Basename::foo::DEBUG idea.

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

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-25 06:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found