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

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 = ''; $n = substr $n, 0, rindex( $n, q{.} );

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

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?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2016-10-01 17:44 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (2 votes). Check out past polls.