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/bin/perl -w
  2 #
  3 # Author: Ralf Schwarz <r...@schwarz.ath.cx>
  4 #         February 20th 2006
  5 #
  6 # returns 0 if host is listening on specified tcp port
  7 #
  8
  9 use strict;
 10 use Socket;
 11
 12 # set time until connection attempt times out
 13 my $timeout = 3;
 14
 15 if ($#ARGV != 1) {
 16   print "usage: is_tcp_port_listening hostname portnumber\n";
 17   exit 2;
 18 }
 19
 20 my $hostname = $ARGV[0];
 21 my $portnumber = $ARGV[1];
 22 my $host = shift || $hostname;
 23 my $port = shift || $portnumber;

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to