in reply to backward split

Sometimes there's just no good reason to use split...

my ($file, $ext) = $string =~ /(.*)\.(.*)/;

-sauoq
"My two cents aren't worth a dime.";

Replies are listed 'Best First'.
(jeffa) 2Re: backward split
by jeffa (Bishop) on Jun 01, 2003 at 01:58 UTC
    ... or a regex (well, directly ;)) ...
    use File::Basename; my @suffix = qw(txt html foobar); my $string = '/path/to/foo.bar.foobar'; my ($file,$path,$ext) = fileparse($string,@suffix);

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)