#!/usr/bin/perl -w use strict; print "Url: "; chomp(my $url = ); if ($url =~ m!\.([^/]+)$!) { print "Ext: $1\n"; } else { print "Not found.\n"; }