http://qs1969.pair.com?node_id=151232

I was never able to find a decent piece of code that was able to parse out the extension of a given file delimited by a '.' regardless of how many '.'s were in the filename. So, I wrote one.

HOW TO USE:

&parse_out_extension($filename);

Comments appreciated on code.

TIA, guys. SnafuX

Updated:
Changed code by removing all DEBUG stuff.
Changed comments in description by removing all references to DEBUG stuff and also removed future plans.
FIXED: where the sub should actually die().

sub parse_out_extension { die("No filename to parse.\n") if ( ! @_ ); my ($file) = @_; my @pieces; map { push(@pieces,$_) } split(/\./,$file); my $end = pop(@pieces); $file =~ s/\.$end//; return($file) if $file; }