Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: gethostname() in perl Message-ID: <7008@jpl-devvax.JPL.NASA.GOV> Date: 7 Feb 90 17:23:32 GMT References: <1018@frankland-river.aaii.oz.au> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 24 In article <1018@frankland-river.aaii.oz.au> pem@frankland-river.aaii.oz.au (Paul E. Maisano) writes: : This is how I find the hostname of the machine I am running on. : : do 'syscall.pl' || die "syscall.pl: $@\n"; : : $host = "\0" x 100; # pre-nulled buffer for hostname : syscall($SYS_GETHOSTNAME, $host, length($host)); : : syscall.pl is just of file of system call numbers. : : I do this because I hate starting up new processes just to find out things : like hostname and date etc. : : It seems a little messy, having to do a direct system call though. : Is there another way, or should perl have a gethostname built in function ? I'm inclined to think it's false economy to avoid starting a process for something that you only have to find out once in a script. Especially when there are workarounds for the desperate, such as syscall. Or seeing what address is bound to your socket and then using gethostbyaddr. But Super Macho Hackers have been wrong before... Larry