I have the following snippet code:
my $hostname = `host \`hostname\``;
which this yields something like :
blahblah.test1234.mydomain.com has address 12.345.67.8910 (I replaced the real values with dummy values)
from here, I want to extract this so that $hostname only has “blahblah.test1234.mydomain.com” and forget the rest
Such piece of code will be ran in different servers so the size of this can vary.
I was thinking using a regular expression that will be cut from the beginning of the line up to mydomain.com so basically *.mydomain.com
You’d probably be better off using perl’s own
gethostbynameorNet::DNS::Resolverinstead of shelling out to a command line program.