It looks like you are trying to extract a part of a string that comes before the period.
use strict;
use warnings;
print StrBefore('abc.com', '.');
#
# This function splits a string into two parts
# at the first occurence of SUBSTR.
# Returns the first half of the string.
#
# Usage: STRING = StrBefore(STRING, SUBSTR)
#
# Example: StrBefore("Abcdef", "cd") --> "Ab"
# StrBefore("abc.us", ".") --> "abc"
# StrBefore("tree", ".") --> "tree"
#
sub StrBefore
{
@_ or return '';
my $S = shift;
defined $S or return '';
length($S) or return '';
@_ or return $S;
my $B = shift;
defined $B or return $S;
length($B) or return $S;
my $P = index($S, $B);
return ($P < 0) ? $S : substr($S, 0, $P);
}