system doesn't do what you want. You should be using backticks:
$hostname = `/bin/hostname`;
Also, you're needlessly using a global for a return value:
sub getHostname { return `/bin/hostname`; } my $hostname = getHostname; print "hostname: $hostname\n";
In reply to Re: not getting hostname correctly on UNIX
by ikegami
in thread not getting hostname correctly on UNIX
by slavam
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |