"Because it's up-side down.
Why is that?
It makes replies harder to read.
Why not?
Please don't top-post." - Sherm Pendley, Mac OS X list

[EMAIL PROTECTED] wrote:
> I, being too lazy to look up a perl function, would use hostname command in
> backticks like so:
> 
> $HostID = `hostname`;
> 

Right which is why the above is "too lazy". Anyone reading this please
don't settle for the above, it is error prone, insecure, and
insufficient. There is no error checking, there at least needs to be a
full path, and it is potentially slower.

> Not sure if that will catch a newline character so I would also follow it
> with this:
> 
> $HostID =~ s/\n//;

Right, in which case we can at least suggest 'chomp',

perldoc -f chomp

http://danconia.org

> 
> -----Original Message-----
> From: Bret Goodfellow [mailto:[EMAIL PROTECTED]
> Sent: Thursday, June 09, 2005 3:36 PM
> To: beginners@perl.org
> Subject: host id
> 
> 
> Simple question to answer, I hope. I am running on an HP-UX system, and
> would like to retrive the UNIX system's host-id (name of box). Is there
> a function to do this?
> 
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to