Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Regex To Remove File Extension (rindex)

by kyle (Abbot)
on Dec 10, 2008 at 19:44 UTC ( #729492=note: print w/ replies, xml ) Need Help??


in reply to Regex To Remove File Extension

Just for the TIMTOWTDI, here's one using substr and rindex:

my $n = 'foo.bar.txt'; $n = substr $n, 0, rindex( $n, q{.} );

In my own code, I'd write s{ \. [^.]+ \z }{}xms


Comment on Re: Regex To Remove File Extension (rindex)
Select or Download Code
Replies are listed 'Best First'.
Re^2: Regex To Remove File Extension (rindex)
by almut (Canon) on Dec 10, 2008 at 21:50 UTC

    ...or, using substr() as an lvalue:

    substr($n,rindex $n,'.') = '';

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (15)
As of 2015-07-28 13:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (254 votes), past polls