Re: "$host = shift || $hostname;" vs. "$host = $hostname;"

2011-11-28 Thread Uri Guttman
On Thu, Nov 24, 2011 at 7:19 PM, JPH wrote: 19 20 my $hostname = $ARGV[0]; 21 my $portnumber = $ARGV[1]; 22 my $host = shift || $hostname; 23 my $port = shift || $portnumber; I'm not sure what the meaning is of this but the thing that is happening is simple enough. You have

Re: "$host = shift || $hostname;" vs. "$host = $hostname;"

2011-11-27 Thread Dr.Ruud
On 2011-11-25 01:08, John W. Krahn wrote: Or use: close SOCKET || die "close: $!"; Instead of the more correct: close SOCKET or die "close: $!"; Well, close takes exactly 1 parameter, so the first variant is working correctly. perl -MO=Deparse -e ' close( SOCKET || die "amai" ) ' close

Re: "$host = shift || $hostname;" vs. "$host = $hostname;"

2011-11-26 Thread Rob Dixon
On 26/11/2011 21:55, Brandon McCaig wrote: I just skimmed perlop again and it doesn't seem to explicitly say that&& and || and other related operators return the last evaluated operand instead of a boolean (the latter being what C and many other "static" languages do). I guess it's just somethi

Re: "$host = shift || $hostname;" vs. "$host = $hostname;"

2011-11-26 Thread Brandon McCaig
On Sat, Nov 26, 2011 at 04:19:58PM +0100, JPH wrote: > Also I wasn't aware of the || construction to use for setting > default values when ARGV (in this case) is undefined. Modern Perls have a new operator, defined-or, which is //. This is similar to || except that it tests the left operand's defi

Re: "$host = shift || $hostname;" vs. "$host = $hostname;"

2011-11-26 Thread John W. Krahn
JPH wrote: I think the below answers my question. Yes. About that. Please do not top-post. TIA. I thought maybe the code was doing some perl magic, but it is probably just a leftover from something else. Also I wasn't aware of the || construction to use for setting default values when ARG

Re: "$host = shift || $hostname;" vs. "$host = $hostname;"

2011-11-26 Thread JPH
I think the below answers my question. I thought maybe the code was doing some perl magic, but it is probably just a leftover from something else. Also I wasn't aware of the || construction to use for setting default values when ARGV (in this case) is undefined. Thnx all! On 11/24/2011 09:05 P

Re: "$host = shift || $hostname;" vs. "$host = $hostname;"

2011-11-24 Thread John W. Krahn
JPH wrote: I found the script below at http://hints.macworld.com/dlfiles/is_tcp_port_listening_pl.txt I am trying to figure out what's happening at lines 20-23. Why is the author using 'shift ||' and not a plain $host = $hostname; Because the author is not a very good Perl p

Re: "$host = shift || $hostname;" vs. "$host = $hostname;"

2011-11-24 Thread Brandon McCaig
Errr,... On Thu, Nov 24, 2011 at 03:05:04PM -0500, Brandon McCaig wrote: > use List::Util; use List::Util q/max/; #^^^ > my $length = max map { ${#$_} } @arrays; my $length = max map { $#{$_} } @arrays; #^^ FTFM. Regards, -- Brandon McCaig C

Re: "$host = shift || $hostname;" vs. "$host = $hostname;"

2011-11-24 Thread Brandon McCaig
Hello: On Thu, Nov 24, 2011 at 07:42:17PM +0100, Rob Coops wrote: > I'm not sure what the meaning is of this but the thing that is happening is > simple enough. You have @ARGV which contains [ 'A host name', 'A port > number']. On line 20 you set $hostname = $ARG

Re: "$host = shift || $hostname;" vs. "$host = $hostname;"

2011-11-24 Thread Rob Coops
t; Why is the author using 'shift ||' and not a plain $host = $hostname; > > Anyone to enlighten me? > > Thanks! > > JP > > --- > > 1 #!/usr/bin/perl -w > 2 # > 3 # Author: Ralf Schwarz > 4 # February 20th 2006 > 5 # > 6 # return

"$host = shift || $hostname;" vs. "$host = $hostname;"

2011-11-24 Thread JPH
I found the script below at http://hints.macworld.com/dlfiles/is_tcp_port_listening_pl.txt I am trying to figure out what's happening at lines 20-23. Why is the author using 'shift ||' and not a plain $host = $hostname; Anyone to enlighten me? Thanks! JP --- 1 #!/usr/

Perl/Syslog: how to control the hostname in the syslog file?

2006-02-14 Thread Ravi Malghan
Hi: I have created a simple script to log syslog messages with the following lines openlog('lab-sensor', 'cons,ndelay,nowait','local7'); syslog('debug', 'this is a test message'); When I run this locally (local hostname: nms02), the following mes

Re: Editing config file entries in between brackets{ } Ex. define host{ hostname value... }

2005-02-22 Thread Wiggins d'Anconia
ormat is like this: define host{ hostname www.google.com ipvalue1 ... ... } define host{ hostname value2 ipvalue2 ... ... } Its all a series of definitions enclosed with brackets. Do you know a better solution to parse this

Editing config file entries in between brackets{ } Ex. define host{ hostname value... }

2005-02-21 Thread Harold Castro
efine host{ hostname www.google.com ipvalue1 ... ... } define host{ hostname value2 ipvalue2 ... ... } Its all a series of definitions enclosed with brackets. Do you know a better solution to parse this file such that

RE: Finding Hosts On Lan - Re: hostname

2003-12-05 Thread Patrick Shoaf
er wrote: > > Thomas Browner wrote: > > > Is there away to find all of the hostname on a lan with > use of perl? > [..] > > You can query DNS to get the hosts in a domain using nslookup, dig, > > host, or similar. For example: > > > >host -l mydomain.com >

RE: Finding Hosts On Lan - Re: hostname

2003-12-04 Thread Bob Showalter
drieux wrote: > On Dec 4, 2003, at 8:18 AM, Bob Showalter wrote: > > Thomas Browner wrote: > > > Is there away to find all of the hostname on a lan with > use of perl? > [..] > > You can query DNS to get the hosts in a domain using nslookup, dig, > > host, or si

Finding Hosts On Lan - Re: hostname

2003-12-04 Thread drieux
On Dec 4, 2003, at 8:18 AM, Bob Showalter wrote: Thomas Browner wrote: Is there away to find all of the hostname on a lan with use of perl? [..] You can query DNS to get the hosts in a domain using nslookup, dig, host, or similar. For example: host -l mydomain.com If you want to talk to the

Re: hostname

2003-12-04 Thread Helgi Briem
Thomas Browner wrote: > Is there away to find all of the hostname on a lan with use of perl? Portable to most systems: use Sys::Hostname; my $host = hostname; or (on Windows systems): my $host = $ENV{COMPUTERNAME}; or (on *nix systems): my $host = $ENV{HOSTNAME}; -- Helgi Briem Tæknide

RE: hostname

2003-12-04 Thread Bob Showalter
Thomas Browner wrote: > Is there away to find all of the hostname on a lan with use of perl? Getting a list of host names involves querying some kind of nameserver or directory service. What kind of LAN? What kind of hosts? You can query DNS to get the hosts in a domain using nslookup, dig, h

[First Response Service] Re: hostname

2003-12-04 Thread Casey West
, legal API for searching newsgroups, so you may also want to try these searches. http://groups.google.com/groups?q=Perl+hostname http://groups.google.com/groups?q=hostname+group%3Acomp.lang.perl.* If you didn't get any useful results below, there's a chance your Subject line was no

hostname

2003-12-04 Thread Thomas Browner
Is there away to find all of the hostname on a lan with use of perl? Thanks, Thomas

hostname for LWP

2003-09-25 Thread George Georgalis
Hi - I just installed perl-5.8.0 from source, in the shell (perl -MCPAN -e shell) I tried to "install LWP" but had some problems until I added an *incorrect* hostname to the 127.0.0.1 line in /etc/hosts my resolver provides correct reverse dns, how do I use that? and how do I manual

Re: newbie question about Sys::Hostname and modules in general

2002-08-02 Thread drieux
On Friday, August 2, 2002, at 08:09 , Chad Kellerman wrote: [..] > ** I always have issues with scope Can I use Sys::Hostname just in > the subroutine, or any perl module for that matter? Or do I have to use > it globally? > > $host=hostname; finds that daggone host

newbie question about Sys::Hostname and modules in general

2002-08-02 Thread Chad Kellerman
Hello, Ok, I made a newbie mistake and I hope I don't have to go back and change my code. I wrote a script that talks to a Mysql database. I created a table called hostname. I created a subroutine to send email messages when that is any errors as well as log them to the db. Pr