Sorry, my bad.
Here's a file that contains variations of the URL, with the digit at the end, at the beginning, in between, and non-existent.
$
$ cat -n f6
1 http://name5.domain.com:8000/file.dat
2 http://na5me.domain.com:8000/file.dat
3 http://5name.domain.com:8000/file.dat
4 http://name.domain.com:8000/file.dat
$
$
Here's the Perl equivalent of your second awk script i.e. remove digit at the end (if present), but retain digit in-between or at the beginning (if present). Otherwise just fetch the word between "//" and "." that does not have any digits.
$
$ perl -lne '/http:\/\/(.*?)(\d)*\..*/ && print $_,"\t=>\t",$1' f6
http://name5.domain.com:8000/file.dat => name
http://na5me.domain.com:8000/file.dat => na5me
http://5name.domain.com:8000/file.dat => 5name
http://name.domain.com:8000/file.dat => name
$
$
Since nothing has been mentioned about the case when the digit is at the beginning or in-between, I shall consider a couple of cases.
Case 1:
The digit at the beginning is to be removed.
The digit in-between has to be retained.
The digit at the end is to be removed.
Which means - "remove digits from the ends, retain it in the middle".
$
$ perl -lne '/http:\/\/(\d)*(.*?)(\d)*\..*/ && print $_,"\t=>\t",$2' f6
http://name5.domain.com:8000/file.dat => name
http://na5me.domain.com:8000/file.dat => na5me
http://5name.domain.com:8000/file.dat => name
http://name.domain.com:8000/file.dat => name
$
Case 2:
The digit at the beginning is to be removed.
The digit in-between has to be removed.
The digit at the end is to be removed.
Which means - "remove digits from the ends and the middle".
$
$ perl -lne 'if (/http:\/\/(\d)*(.*?)(\d)*\..*/){ ($x = $2) =~ s/\d//g; print $_,"\t=>\t",$x}' f6
http://name5.domain.com:8000/file.dat => name
http://na5me.domain.com:8000/file.dat => name
http://5name.domain.com:8000/file.dat => name
http://name.domain.com:8000/file.dat => name
$
tyler_durden