I failed extracting a hostname which might be both a FQDN and simple hostname
For example with sed it works fine:
echo test_serv1.TEST-Site-1.test.com|sed 's/\..*//'
test_serv1
echo test_serv1|sed 's/\..*//'
test_serv1
But in Perl I get only when its FQDN:
my $t='test_serv1.TEST-Site-1.test.com';
my ($res) = $t=~ /^(.*?)\./;
print "$res\n";
I tried different combinations for test_serv1, but it does not work, why ?
Why don’t you use the same method for perl?