Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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
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 musing on the Monastery: (11)
As of 2014-09-18 20:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (124 votes), past polls