in reply to Probably silly regex question / not so silly regex question

You suggested that split wouldn't work if there was a dot in the extension. It just might, in fact, still work using split...and adding a join.
@dissection = split /\./, $filename; $ext = pop(@dissection); $id = join(".",@dissection);


- Infinityandbeyond

Replies are listed 'Best First'.
Another The (split) answer
by gryng (Hermit) on Aug 02, 2000 at 00:30 UTC
    While we are doing high level manipulations, you can also do:
    ($name,$ext) = reverse map {scalar reverse} (split /\./, (reverse $fil +ename), 2);

    Ciao,
    Gryn

      Or:
      my( $name, $ext ); { my @chunks = split/\./, $filename; $ext = pop @chunks; $name = join '.', @chunks; }
      If you don't like reverse for some reason.

      Actually I really liked gryng's answer... I was just trying to thing of another way to do it using split.

      For them that like one-liners:

      my( $ext, $name )=(@_=split/\./, $filename and pop @_, join '.', @_);