$ perl -E ' my @images = qw{a.png b.gif c.svg d.jpg}; for (@images) { say substr $_, rindex $_, "."; } ' .png .gif .svg .jpg