On Sat, 20 Nov 2004, Bob Showalter wrote:
> [EMAIL PROTECTED] wrote:
> >
> > I need to capture the current system name to a variable. I am doing
> > like below but the hostname value is not getting stored in the
> > variable. any suggestions please ??
> >
> > -----------------------------------------
> > $systemserver = system("hostname");
> > ----------------------------------
>
> See
>
> perldoc -q 'Why can't I get the output of a command with system()?'
>
> Also, consider using the standard module Sys::Hostname.
This is the right answer -- there's no good reason to use a system call
for this, especially considering that `hostname` isn't necessarily
portable, but Sys::Hostname will attempt to look up the system name in a
variety of ways that should reliably work on all platforms.
It's good to know how to capture the output of system commands, but in
this case (as in a lot of other cases), you probably shouldn't be
approaching the problem that way to begin with.
--
Chris Devers
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>