[16379] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3791 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 24 21:10:31 2000

Date: Mon, 24 Jul 2000 18:10:19 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <964487419-v9-i3791@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 24 Jul 2000     Volume: 9 Number: 3791

Today's topics:
    Re: NetBIOS/nbname ??? <coy@coystoys.com>
    Re: NetBIOS/nbname ??? <flavell@mail.cern.ch>
    Re: NetBIOS/nbname ??? (John Stanley)
    Re: NetBIOS/nbname ??? (jason)
    Re: NetBIOS/nbname ??? (jason)
    Re: NetBIOS/nbname ??? (John Stanley)
    Re: NetBIOS/nbname ??? (jason)
    Re: perl as part of unix distribution (Logan Shaw)
    Re: perl as part of unix distribution <peter.sundstrom@eds.com>
    Re: perl as part of unix distribution (NP)
    Re: Post Form AND redirect <flavell@mail.cern.ch>
    Re: Question about redirecting output in perl on NT <theglauber@my-deja.com>
    Re: Setting $/ from variable - accepting meta character (Keith Calvert Ivey)
    Re: sort with use strict (Abigail)
    Re: String Interpolation of Typeglobs <bart.lateur@skynet.be>
    Re: String Interpolation of Typeglobs <tony_curtis32@yahoo.com>
    Re: StudlyCaps (was: HELP: longSyntax ok, but: rHsh->{m (Lupe Christoph)
        USEing a perl module <jheide@sprint.ca>
    Re: user entered IP or Domain ? (Logan Shaw)
    Re: user entered IP or Domain ? (John Stanley)
    Re: user entered IP or Domain ? (Logan Shaw)
    Re: user entered IP or Domain ? (Abigail)
    Re: user entered IP or Domain ? <coy@coystoys.com>
    Re: Viewing HTTP headers (Charles DeRykus)
    Re: Why use anonymous? <mjcarman@home.com>
    Re: Why use anonymous? (Tim)
    Re: Why use anonymous? <bart.lateur@skynet.be>
    Re: Why won't  "use strict;"  work? (BUCK NAKED1)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 24 Jul 2000 22:10:25 GMT
From: "Coy" <coy@coystoys.com>
Subject: Re: NetBIOS/nbname ???
Message-Id: <l93f5.9273$Mt.102842@nnrp1.ptd.net>


"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message news:397CB857.4E884DC1@stomp.stomp.tokyo...
: Terrill_b wrote:
:
: > At places like:
:
: >    http://grc.com
:
: > Steve Gibson gets your name from your computer. I suspect he's using
: > something like nbname in NetBIOS.
:
: > Been trying now for several months (not non-stop, of course <g>)
: > to figure this out.
:
: > Someone know how it's done in Perl???
:
:
: Simple port scanner and a few tricks to communicate with
: Windows web server and Windows telnet application.
:
: Why bother writing this in Perl? Programs like this are
: available by the dozens, some free, some shareware and
: some commercial programs.
:
: Why bother at all? A person with a bit of imagination
: can deal with security quite effectively. I am running
: no special software, no Guard Dog, no Black Ice, nada.
: Famous GRC cannot touch a system like mine:
:
:
: Port Service   Status    Security Implications
:
: 21     FTP    Stealth!   There is NO EVIDENCE WHATSOEVER that
:                          a port (or even any computer) exists
:                          at this IP address!
:
: 23   Telnet   Stealth!   There is NO EVIDENCE WHATSOEVER that
:                          a port (or even any computer) exists
:                          at this IP address!
:
: 25    SMTP    Stealth!   There is NO EVIDENCE WHATSOEVER that
:                          a port (or even any computer) exists
:                          at this IP address!
:
: 79   Finger   Stealth!   There is NO EVIDENCE WHATSOEVER that
:                          a port (or even any computer) exists
:                          at this IP address!
:
: 80    HTTP    Stealth!   There is NO EVIDENCE WHATSOEVER that
:                          a port (or even any computer) exists
:                          at this IP address!
:
: 110   POP3    Stealth!   There is NO EVIDENCE WHATSOEVER that
:                          a port (or even any computer) exists
:                          at this IP address!
:
: 113  IDENT    Closed     Your computer has responded that this
:                          port exists but is currently closed to
:                          connections.
:
: 139  NetBIOS  Stealth!   There is NO EVIDENCE WHATSOEVER that
:                          a port (or even any computer) exists
:                          at this IP address!
:
: 143  IMAP     Stealth!   There is NO EVIDENCE WHATSOEVER that
:                          a port (or even any computer) exists
:                          at this IP address!
:
: 443  HTTPS    Stealth!   There is NO EVIDENCE WHATSOEVER that
:                          a port (or even any computer) exists
:                          at this IP address!
:
:
: However, I can get into your computer,
: at whim and will and, do many things
: which would shock you. Just a matter
: of know how. This is very safe, very
: gentle and there is no way to prevent
: this from happening:
:
: print "file:///%43|%2f";
:
: Doesn't work for MAC / Apple and some
: Linux systems. Those are not computers
: but rather fancy Etch-A-Sketch toys.
:

very interesting.
now, how do u do it in perl ?





------------------------------

Date: Mon, 24 Jul 2000 23:54:19 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: NetBIOS/nbname ???
Message-Id: <Pine.GHP.4.21.0007242351580.1335-100000@hpplus03.cern.ch>

On Mon, 24 Jul 2000, Coy wrote:

> well, if he's on a windows machine,
> 
> $REMOTE_ADDR = $ENV('REMOTE_ADDR');

This is likely to be the address of the proxy server that the client
uses.

> print system('nbtstat -A $REMOTE_ADDR');

Proxy servers usually won't respond to that; even if they did, it
won't do you much good.

Of course, this has nothing specifically to do with Perl.


Oh look, an upside-down fullquoter.  I should've known.  



------------------------------

Date: 24 Jul 2000 22:44:24 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: NetBIOS/nbname ???
Message-Id: <8ligs8$m3n$1@news.NERO.NET>

In article <e52Zw1a9$GA.435@cpmsnbbsa08>,
Terrill_b <Terrill@Bennett.org> wrote:
>Inquiring minds want to know...
>
>At places like:
>   http://grc.com
>
>Steve Gibson gets your name from your computer. 

No, not here he doesn't.

>Someone know how it's done in Perl???

Well, if he's getting your system's name, then you've got a PTR record
in DNS and he looks up the name for the system that is connecting. 



------------------------------

Date: Mon, 24 Jul 2000 23:22:12 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: NetBIOS/nbname ???
Message-Id: <MPG.13e76cf89305003989684@news>

Alan J. Flavell writes ..
>On Mon, 24 Jul 2000, Coy wrote:
>
>> well, if he's on a windows machine,
>> 
>> $REMOTE_ADDR = $ENV('REMOTE_ADDR');
>
>This is likely to be the address of the proxy server that the client
>uses.

actually it's likely to be a syntax error [perldata]

the question arises why Coy is trying to assign one scalar to another 
anyway .. what _is_ this aversion people seem to have to using elements 
of hashes and arrays in their expressions ?

>> print system('nbtstat -A $REMOTE_ADDR');
>
>Proxy servers usually won't respond to that; even if they did, it
>won't do you much good.

only Windows will respond to that with something along the lines of

  The IP address is not in the correct format. It needs to be
  dotted decimal, for example 11.11.12.13
  You entered "$REMOTE_ADDR"

and even if the single-quote usage is corrected [perlop] the print 
statement will needlessly print out the return value of the system call 
[-f system] after the nbtstat has finished printing on STDOUT

  ( at the command prompt - stick perldoc in front of anything in )
  (  brackets above to see documentation on the preceeding issue  )

-- 
  jason -- elephant@squirrelgroup.com --


------------------------------

Date: Mon, 24 Jul 2000 23:31:03 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: NetBIOS/nbname ???
Message-Id: <MPG.13e76f0f76fd90aa989685@news>

John Stanley writes ..
>In article <e52Zw1a9$GA.435@cpmsnbbsa08>,
>Terrill_b <Terrill@Bennett.org> wrote:
>>Inquiring minds want to know...
>>
>>At places like:
>>   http://grc.com
>>
>>Steve Gibson gets your name from your computer. 
>
>No, not here he doesn't.
>
>>Someone know how it's done in Perl???
>
>Well, if he's getting your system's name, then you've got a PTR record
>in DNS and he looks up the name for the system that is connecting. 

John .. it's actually a Windows thing called NetBIOS used mainly for LAN 
communications that - by default - is exposed over TCP/IP

-- 
  jason -- elephant@squirrelgroup.com --


------------------------------

Date: 25 Jul 2000 00:29:42 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: NetBIOS/nbname ???
Message-Id: <8lin1m$o0h$1@news.NERO.NET>

In article <MPG.13e76f0f76fd90aa989685@news>,
jason <elephant@squirrelgroup.com> wrote:
>John Stanley writes ..
>>In article <e52Zw1a9$GA.435@cpmsnbbsa08>,
>>Terrill_b <Terrill@Bennett.org> wrote:
>>>Inquiring minds want to know...
>>>
>>>At places like:
>>>   http://grc.com
>>>Steve Gibson gets your name from your computer. 
>>
>>No, not here he doesn't.
>>
>>>Someone know how it's done in Perl???
>>
>>Well, if he's getting your system's name, then you've got a PTR record
>>in DNS and he looks up the name for the system that is connecting. 
>
>John .. it's actually a Windows thing called NetBIOS used mainly for LAN 
>communications that - by default - is exposed over TCP/IP

Actually, if he's getting the name of my computer then it isn't a
"Windows" thing called NetBIOS, it's a DNS thing called a PTR record.
Just like I said.



------------------------------

Date: Tue, 25 Jul 2000 00:48:51 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: NetBIOS/nbname ???
Message-Id: <MPG.13e781398895beb7989688@news>

John Stanley writes ..
>In article <MPG.13e76f0f76fd90aa989685@news>,
>jason <elephant@squirrelgroup.com> wrote:
>>John Stanley writes ..
>>>In article <e52Zw1a9$GA.435@cpmsnbbsa08>,
>>>Terrill_b <Terrill@Bennett.org> wrote:
>>>>Inquiring minds want to know...
>>>>
>>>>At places like:
>>>>   http://grc.com
>>>>Steve Gibson gets your name from your computer. 
>>>
>>>No, not here he doesn't.
>>>
>>>>Someone know how it's done in Perl???
>>>
>>>Well, if he's getting your system's name, then you've got a PTR record
>>>in DNS and he looks up the name for the system that is connecting. 
>>
>>John .. it's actually a Windows thing called NetBIOS used mainly for LAN 
>>communications that - by default - is exposed over TCP/IP
>
>Actually, if he's getting the name of my computer then it isn't a
>"Windows" thing called NetBIOS, it's a DNS thing called a PTR record.
>Just like I said.

umm .. that's not what you said .. you said "if he's getting your 
system's name" .. it's a silly argument because what you originally said 
is still quoted above

(and just quietly .. IF he got YOUR system name then it would also a 
Windows thing over NetBIOS because that's the ONLY way he (Steve Gibson) 
tries to get system names on the web site mentioned by the originator .. 
of course if you have no NetBIOS exposure then that 'if' will always be 
false .. but the statement is still correct)

-- 
  jason -- elephant@squirrelgroup.com --


------------------------------

Date: 24 Jul 2000 17:43:05 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: perl as part of unix distribution
Message-Id: <8ligpp$ev1$1@provolone.cs.utexas.edu>

In article <8licgm$arm$1@nnrp1.deja.com>,  <dgallardo@my-deja.com> wrote:
>Solaris 8 ships with perl?  We're using Solaris 7, which does not...

Not only does Solaris 8 ship with perl, you can't not install it.

And of course, it's is nice to automatically have it there, but also
it's already out of date:

	$ uname -sr
	SunOS 5.8
	$ /usr/bin/perl -e 'print $], "\n";' 
	5.00503
	$ /usr/local/bin/perl -e 'print $], "\n";'
	5.006
	$ 

Such is the fate of everything that comes with the OS...

Now, if Sun would just use perl to speed up that installpatch process.
It seems to be written in ksh right now, and it takes something like
one minute per patch.  That's just ridiculous.

  - Logan


------------------------------

Date: Tue, 25 Jul 2000 10:42:10 +1200
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: perl as part of unix distribution
Message-Id: <8ligoj$jvc$1@hermes.nz.eds.com>


dgallardo@my-deja.com wrote in message <8li2a5$2tk$1@nnrp1.deja.com>...
>Sorry if this is off topic or inflammatory.
>
>Is perl part of any standard unix distribution?  Are there any moves in
>this direction.

Almost all Unix flavours now offer, or will offer Perl as part of the
standard distribution.

Solaris 8 ships with perl 5.005_3


>I like to use perl in shell scripts for program installation and
>maintenance but my sysadmin will not allow perl on production systems.
>I hate to think that I'll have to rewrite the perl bits in sed or awk.
>
>Do other folks have similarly recalcitrant sysadmins?  (I mean with
>regards to perl.  I know they're paid to be hardasses.)


Get your sysadmin to remove *all* the parts of the OS that haven't been
produced by the OS vendor, then have a good laugh at them trying to make the
system usable.




------------------------------

Date: Mon, 24 Jul 2000 23:56:43 GMT
From: nvp@spamnothanks.speakeasy.org (NP)
Subject: Re: perl as part of unix distribution
Message-Id: <%I4f5.141402$t91.1083759@news4.giganews.com>

On 24 Jul 2000 17:43:05 -0500, Logan Shaw <logan@cs.utexas.edu> wrote:
: 
: Not only does Solaris 8 ship with perl, you can't not install it.

Yes you can.  Well, let me rephrase; you can "get jiggy wit"
/var/sadm/install/contents and toast it from there, along with
/var/sadm/pkg once you've been forced to install it.  :-)  Then again,
the *BSD's force you to install Perl as part of the core -- so you've
got the same installation issues there.

: And of course, it's is nice to automatically have it there, but also
: it's already out of date:

IMO, I'd rather use 5.005_03 at this point -- at least until we see
maintenance releases of 5.6.0.

-- 
Nate II



------------------------------

Date: Mon, 24 Jul 2000 23:58:47 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Post Form AND redirect
Message-Id: <Pine.GHP.4.21.0007242355310.1335-100000@hpplus03.cern.ch>

On Mon, 24 Jul 2000 zagar@my-deja.com wrote:

> What I'm trying to do is combine the two, to redirect to another page,
> and the redirect CONTAINS a form that I have generated completely with
> Perl.

HTTP redirection in response to a POST is problematical, but has
nothing to do with Perl as such.  I even have a page on the topic: if
you can't find it in the proper way, ask on an appropriate newsgroup
(f'up set) and I'll look it out for you.

For more focussed advice we'd need to know what you're trying to
achieve, rather than only being told your apparently failed solution
to some only vaguely stated problem.

good luck



------------------------------

Date: Mon, 24 Jul 2000 22:20:12 GMT
From: The Glauber <theglauber@my-deja.com>
Subject: Re: Question about redirecting output in perl on NT
Message-Id: <8lifen$d7u$1@nnrp1.deja.com>

In article <8lidun$bt3$1@nnrp1.deja.com>,
  sbhide@my-deja.com wrote:
> Hi,
>
> 	I have this strange problem on NT 4.0.
>
> I have a simple script given below:
> ----
> print "Hello World!\n";
> ---
>
> when I installed perl on my machine I allowed the installer to
> associate .pl scripts with perl program so that i can just
> say "test.pl" on a command window and it executes the script. however
> this has a side effect and that is when I redirect the output onto a
> file, it is created without any contents now.
>
> i.e.
>
> C:\temp> test.pl > t
> 	->> here t is empty after the command
>
> however, if i run it explicitly as perl -w test.pl > t
> 	->> the t file has "Hello World!" in it.
>
> what is going on here?


Ask Bill Gates... Redirection is ugly and broken in NT, even worse in
9x. There is a little note about this in the "quirks" document (in case
you're using Activestate's Perl), under the "ActivePerl FAQ section of
the documentation. If you use pl2bat to convert your script to a batch
file, the redirection should work.


--
Glauber Ribeiro
theglauber@my-deja.com    http://www.myvehiclehistoryreport.com
"Opinions stated are my own and not representative of Experian"


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Mon, 24 Jul 2000 23:36:41 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Setting $/ from variable - accepting meta characters
Message-Id: <397cd2a9.5027344@news.newsguy.com>

Larry Rosler <lr@hpl.hp.com> wrote:
>In article <8lh6le$dil$1@nnrp1.deja.com>, aqutiv@my-deja.com says...

>> \cn, \xnn, and \0nn are escape
>> sequence that conclude more the one following chars.
>
>What about \0n and \0nnn ?

What about \1nn and \2nn?

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


------------------------------

Date: 24 Jul 2000 18:26:35 EDT
From: abigail@foad.org (Abigail)
Subject: Re: sort with use strict
Message-Id: <slrn8npgkm.vcg.abigail@alexandra.foad.org>

Young (noemail@noemail.com) wrote on MMDXIX September MCMXCIII in
<URL:news:397CABB7.4FACCF94@noemail.com>:
~~ 
~~ How come I don't need to declare $a and $b with the following line, when
~~ I use strict? How come I get an error if I do declare those variables?

Have you read the manpage? It explicitely talks about this. Djees.


Abigail
-- 
$"=$,;*{;qq{@{[(A..Z)[qq[0020191411140003]=~m[..]g]]}}}=*_=sub{print/::(.*)/};
$\=$/;q<Just another Perl Hacker>->();


------------------------------

Date: Tue, 25 Jul 2000 00:21:29 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: String Interpolation of Typeglobs
Message-Id: <38npnsg1urrqnekb71g23v46648dg6qctj@4ax.com>

Mark Rawizza wrote:

>1:  @spud = ("idaho", "russet");
>2:  *potato = *spud;
>3:  print "@potato\n";
>
>This will return the following:
>
>==> In string, @potato now must be written as \@potato at try.pl line 3,
>near "@potato"
>==> Execution of try.pl aborted due to compilation errors.
>
>Is this a bug?

Not really.

It's just that you haven't mentioned the array @potatoe in your source
before that point. The typeglob doesn't count.

	@spud = ("idaho", "russet");
	@potato = (); # for example
	*potato = *spud;
	print "@potato\n";

The same problem occurs if you set @potatoe in a file that you
require(). At compile time, Perl doesn't know about this yet, and it
will complain about it just as well.

-- 
	Bart.


------------------------------

Date: 24 Jul 2000 19:54:28 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: String Interpolation of Typeglobs
Message-Id: <87zon7uj0b.fsf@limey.hpcc.uh.edu>

>> On Tue, 25 Jul 2000 00:21:29 GMT,
>> Bart Lateur <bart.lateur@skynet.be> said:

> It's just that you haven't mentioned the array
> @potatoe

Shouldn't there be a

    use Quayle;

here? :-)

-- 
"With $10,000, we'd be millionaires!"
                                           Homer Simpson


------------------------------

Date: 24 Jul 2000 23:56:50 +0200
From: lupe@alanya.lupe-christoph.de (Lupe Christoph)
Subject: Re: StudlyCaps (was: HELP: longSyntax ok, but: rHsh->{myKey} UNDEFINED??)
Message-Id: <8lie32$s24$1@alanya.lupe-christoph.de>

Ilmari Karonen <iltzu@sci.invalid> writes:

>In article <8li2os$hmo$2@slb1.atl.mindspring.net>, David Combs wrote:
>>
>>. I like long names that fully describe what the variable is --
>>   even VERY long names (30 chars and more).

>Well, that is like saying: "I like swimming in freezing cold water."

>There's absolutely nothing wrong with that, of course, if you really
>do like it - thousands if not millions of Finns would agree with you.

>You are, however, expected to stop before complaining of the cold.

I thought, the idea is to stop before it is frozen?
-- 
| lupe@lupe-christoph.de       |        http://free.prohosting.com/~lupe |
| "jryy vg ybbxf yvxr gur l2x oht qvqa'g erne vg'f htyl urnq." "lrc. gur |
| qbbzfnlref unir orra cebira jebat lrg ntnva."  ....  "qvq lbh frr gung |
| gbb?" "ubhfgba. jr unir n ceboyrz."           User Friendly 2000-01-01 |


------------------------------

Date: Mon, 24 Jul 2000 17:15:36 -0700
From: "Glen Heide" <jheide@sprint.ca>
Subject: USEing a perl module
Message-Id: <v05f5.95$fV5.4001@newscontent-01.sprint.ca>

What are the steps to making a perl file use a perl module?

On the server I use (paid server), they don't have the MIME::Lite module, so
I have to install it myself... though I've been having no luck so far.

It works fine on my own computer, and all I added was what I was told:

use lib "/mydir/mylib";
use MIME::Lite

*blahblahblah*

Is there anything else that I was suppose to add other then those 2 lines?
Is there any specific thing that I should remember about the first line?
Any response will be greatly appreciated   :)


--
    Yours Truly,
        Glen Heide




------------------------------

Date: 24 Jul 2000 17:48:59 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: user entered IP or Domain ?
Message-Id: <8lih4r$f04$1@provolone.cs.utexas.edu>

In article <qc2f5.9211$Mt.102121@nnrp1.ptd.net>, Coy <coy@coystoys.com> wrote:
>I'm looking for a simple way to tell if the user entered
>an IP address, or a domain name.
>
>example:
>    ./program.pl 192.168.123.1
>    or
>    ./program.pl some.host.domain.com
>    or
>    ./program.pl host.domain.com
>
>the host will not always have reverse dns,
>so I can't check with inet_ntoa();

O.K., silly question: why do you care?  You can use them
interchangeably, and it won't hurt you to do a gethostbyname() on an IP
address.  At least, it shouldn't.

If you really want to check a variable to see if it's an ip address, do
this:

	if ($myvar =~ /^(\d+[.]){3}\d+$/)
		{ print "It's an IP address\n"; }
	else
		{ print "Apparently, it's a hostname.\n"; }

Actually, that's not perfect because it will allow 999.0.0.0 as an IP
address, but it is pretty close.

  - Logan


------------------------------

Date: 24 Jul 2000 22:52:21 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: user entered IP or Domain ?
Message-Id: <8lihb5$m7h$1@news.NERO.NET>

In article <8lih4r$f04$1@provolone.cs.utexas.edu>,
Logan Shaw <logan@cs.utexas.edu> wrote:
>In article <qc2f5.9211$Mt.102121@nnrp1.ptd.net>, Coy <coy@coystoys.com> wrote:
>>I'm looking for a simple way to tell if the user entered
>>an IP address, or a domain name.

>If you really want to check a variable to see if it's an ip address, do
>this:
>
>	if ($myvar =~ /^(\d+[.]){3}\d+$/)

>Actually, that's not perfect because it will allow 999.0.0.0 as an IP
>address, but it is pretty close.

It will fail on 127.1 and 3428965200, which makes it a lot further away
than you thought.



------------------------------

Date: 24 Jul 2000 18:02:25 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: user entered IP or Domain ?
Message-Id: <8lihu1$f3r$1@provolone.cs.utexas.edu>

In article <8lihb5$m7h$1@news.NERO.NET>,
John Stanley <stanley@skyking.OCE.ORST.EDU> wrote:
>In article <8lih4r$f04$1@provolone.cs.utexas.edu>,
>Logan Shaw <logan@cs.utexas.edu> wrote:
>>In article <qc2f5.9211$Mt.102121@nnrp1.ptd.net>, Coy <coy@coystoys.com> wrote:
>>>I'm looking for a simple way to tell if the user entered
>>>an IP address, or a domain name.
>
>>If you really want to check a variable to see if it's an ip address, do
>>this:
>>
>>	if ($myvar =~ /^(\d+[.]){3}\d+$/)
>
>>Actually, that's not perfect because it will allow 999.0.0.0 as an IP
>>address, but it is pretty close.
>
>It will fail on 127.1 and 3428965200, which makes it a lot further away
>than you thought.

Nah, it makes it exactly as close as I thought.  I just didn't happen
to mention it because I didn't think it was terribly important.  I
suppose it's possible that somebody actually does use "127.1" as a
shortcut for "127.0.0.1", but I don't really think it would phase me if
my program didn't support that.

But you are right; it will fail on those.  If you like, use

	if ($myvar =~ /^(\d+[.])*\d+$/)

instead.

  - Logan


------------------------------

Date: 24 Jul 2000 19:29:29 EDT
From: abigail@foad.org (Abigail)
Subject: Re: user entered IP or Domain ?
Message-Id: <slrn8npkaj.vcg.abigail@alexandra.foad.org>

Logan Shaw (logan@cs.utexas.edu) wrote on MMDXIX September MCMXCIII in
<URL:news:8lihu1$f3r$1@provolone.cs.utexas.edu>:
!! In article <8lihb5$m7h$1@news.NERO.NET>,
!! John Stanley <stanley@skyking.OCE.ORST.EDU> wrote:
!! >In article <8lih4r$f04$1@provolone.cs.utexas.edu>,
!! >Logan Shaw <logan@cs.utexas.edu> wrote:
!! >>In article <qc2f5.9211$Mt.102121@nnrp1.ptd.net>, Coy <coy@coystoys.com> wrote:
!! >>>I'm looking for a simple way to tell if the user entered
!! >>>an IP address, or a domain name.
!! >
!! >>If you really want to check a variable to see if it's an ip address, do
!! >>this:
!! >>
!! >>	if ($myvar =~ /^(\d+[.]){3}\d+$/)
!! >
!! >>Actually, that's not perfect because it will allow 999.0.0.0 as an IP
!! >>address, but it is pretty close.
!! >
!! >It will fail on 127.1 and 3428965200, which makes it a lot further away
!! >than you thought.
!! 
!! Nah, it makes it exactly as close as I thought.  I just didn't happen
!! to mention it because I didn't think it was terribly important.  I
!! suppose it's possible that somebody actually does use "127.1" as a
!! shortcut for "127.0.0.1", but I don't really think it would phase me if
!! my program didn't support that.
!! 
!! But you are right; it will fail on those.  If you like, use
!! 
!! 	if ($myvar =~ /^(\d+[.])*\d+$/)


But that would allow 127.1.2.3.4.5.6. 

    /^(\d+[.]){,3}\d+$/


Abigail
-- 
# Perl 5.6.0 broke this.
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


------------------------------

Date: Mon, 24 Jul 2000 23:40:10 GMT
From: "Coy" <coy@coystoys.com>
Subject: Re: user entered IP or Domain ?
Message-Id: <ut4f5.9301$Mt.103731@nnrp1.ptd.net>


"Logan Shaw" <logan@cs.utexas.edu> wrote in message news:8lih4r$f04$1@provolone.cs.utexas.edu...
: In article <qc2f5.9211$Mt.102121@nnrp1.ptd.net>, Coy <coy@coystoys.com> wrote:
: >I'm looking for a simple way to tell if the user entered
: >an IP address, or a domain name.
: >
: >example:
: >    ./program.pl 192.168.123.1
: >    or
: >    ./program.pl some.host.domain.com
: >    or
: >    ./program.pl host.domain.com
: >
: >the host will not always have reverse dns,
: >so I can't check with inet_ntoa();
:
: O.K., silly question: why do you care?  You can use them
: interchangeably, and it won't hurt you to do a gethostbyname() on an IP
: address.  At least, it shouldn't.

Well, im making a whois query program.
I need to know if its a domainname or an IP address
so to query the proper servers.

gethostbyname() works on an IP address.
however
nslookup www.somehost.com
Name: www.somehost.com
Address: 192.168.123.1

nslookup 192.186.123.1

Name: virt-1.someotherdomain.net
Address: 192.186.123.1

This could pose a problem as u could see.
$domainname = gethostbyaddr(inet_aton($ipaddress),AF_INET)
would return virt-1.someotherdomain.net.


Since im very much the amature perl programmer,
I'm still getting used to 'pattern matching' and I knew
there was a way to figure out of everything in a variable
was decimal or not.
(which im guessing the /D does .. but i will reference later)

I'll try your:
($myvar =~ /^(\d+[.])*\d+$/)

in your other post instead :)

Thanks for the reply's.





------------------------------

Date: Mon, 24 Jul 2000 21:58:40 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Viewing HTTP headers
Message-Id: <Fy82Ds.5FL@news.boeing.com>

In article <8l0mhi$khl$1@news.netvision.net.il>,
Guy <guymal@hotmail.com> wrote:
>I don't want to see what http headers the server returns ( I know how to do
>that). I want to see what http headers the web server RECEIVES from the html
>form that is submitted to it.
>

You might want to try Tim Meadowcroft's HTTP sniffer.
Here's a summary I ran across: 
  
 HttpSniffer.pl (at http://www.compansr.demon.co.uk) is
 designed for debugging HTTP conversations. It doesn't hack
 into the TCP/IP stack, instead it runs as a tunnel - you
 start up the sniffer and tell it where to forward HTTP
 requests to (the real server), and then point the browsing
 app at the sniffer. It dumps the headers of the HTTP request
 and replies as it processes them.
  
 It's free, it has many authors, and the primary author will
 support it by answering any questions you have. It was
 originally written to debug cookie transactions, but it's
 quite a handy tool for other tasks too.


Here's some sample output I just got:

--
Charles DeRykus

 --> C10 --> S12 ==== (761) Request <GET http://search.cpan.org/search?dist=CGI.
pm HTTP/1.0>
 --> C10 --> S12 GET http://search.cpan.org/search?dist=CGI.pm HTTP/1.0
 --> C10 --> S12 Proxy-Connection: Keep-Alive
 --> C10 --> S12 User-Agent: Mozilla/4.72C-Boeing UNIX Kit [en] (X11; U; SunOS 5
 .7 sun4u)
 --> C10 --> S12 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, im
age/png, */*
 --> C10 --> S12 Accept-Encoding: gzip
 --> C10 --> S12 Accept-Language: en
 --> C10 --> S12 Accept-Charset: iso-8859-1,*,utf-8
 --> C10 --> S12 ==== Body was 0 bytes


------------------------------

Date: Mon, 24 Jul 2000 16:31:56 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Why use anonymous?
Message-Id: <397CB5CC.15841010@home.com>

awilcox@contract.East.Sun.COM wrote:
> 
>   I have been doing Perl for a long time (since ~1995)

Some here would argue that you're still a Perl pup. :)

> in that time, I have never found a need to use anonymous
> hashes/subroutines (were they even available in Perl 4?).

No, I don't believe so... anonymous things rely on the use of
references, which (IIRC) were introduced in Perl 5.

> I had a job interview some time ago where a smarmy little
> know-it-all, who's been Perl-ing for all of 6 months, quizzed
> me on my Perl abilities.
> [...]
> he dragged out these anonymous hashes and such, which, to my 
> knowledge, I have never needed or used, and thus said "Huh?".

Sometimes you just don't care what your data is called. :)

An anonymous list/hash/sub is just one that doesn't have a name. It
exists because it has a non-zero reference count. (I.e. no name, but
somebody out there knows about it.)

You may well have used this stuff without knowing the term for it. Have
you ever used data structures more complicated than scalars, arrays, and
hashes? e.g. a list-of-lists (LoL) or a hash-of-hashes (HoH)? A LoL is
(in implementation) an array of references. Those references point to
unnamed (and hence anonymous) arrays. [Well, they could be references to
named arrays as well, but that's rarer.]

Anonymous subroutines are useful if you need to create a sub on the fly
-- build it up and call it through its reference. You can use them to
create 'localized' subroutines. I usually use them when creating
callbacks for Tk widgets -- I don't want to write a named sub for every
little thing, so I just make an anonymous one. (Tk widgets take coderefs
as args.)

So, anonymous arrays/hashes/subs are quite useful, even if you don't
absolutely need them much of the time.

> He couldn't give me an answer as to why one would use these,

Heh. Then he shouldn't have been asking the question. How would he know
how to interpret your response?

HTH.
-mjc


------------------------------

Date: Mon, 24 Jul 2000 23:28:33 GMT
From: SPAM+indigo@dimensional.com (Tim)
Subject: Re: Why use anonymous?
Message-Id: <8F7BB39D4indigodimcom@166.93.207.145>

awilcox@contract.East.Sun.COM wrote in 
<8lhvnm$l54$1@eastnews1.east.sun.com>:

>
>Hi all,
>  I have been doing Perl for a long time (since ~1995) and
>in that time, I have never found a need to use anonymous 
>hashes/subroutines (were they even available in Perl 4?).
>I had a job interview some time ago where a smarmy little
>know-it-all, who's been Perl-ing for all of 6 months, quizzed
>me on my Perl abilities.  He tried to stump me with regexes, 
>but I had just finished a project where I had done a lot of
>them, so no dice there :-)  So then, he dragged out these anonymous
>hashes and such, which, to my knowledge, I have never needed or 
>used, and thus said "Huh?".

You ever use an array of hashes?  If so, then you probably used
anonymous hashes.  

"What is an anonymous hash?" is one my standard interview questions,
and most people miss it.  However, a lot of them understand what
they are if I prompt them about nested data structures.

-T


------------------------------

Date: Tue, 25 Jul 2000 00:13:56 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Why use anonymous?
Message-Id: <7dmpnscmgd7qdf6opnauf6mn2c5eugso4i@4ax.com>

awilcox@contract.East.Sun.COM () wrote:

>So, to recap, why would you use an anonymous hash or
>subroutine, as opposed to their named counterparts?

Anonymous hashes: as records, in a database.

	@records = ( { name => 'Fred', age => 43 }, 
		     { name => 'Barney', age => 41 });
	foreach my $record (@records) {
	    print "name: $record->{name}, age = $record->{age}\n";
	}

Anonymous subroutines: for example, callbacks, as when using File::Find.
Perl's version of switch statements

	%switch = ( foo => sub { print "I do this when you see 'foo'!\n"
}, bar => sub { print "I get all excited when you give me a 'bar'!\n" }
);
                             
	foreach (qw(foo bar baz)) {
	    print "$_: ";
	    ($switch{$_} || sub { print "(default)\n"})->($_);
	}
	
-- 
	Bart.


------------------------------

Date: Mon, 24 Jul 2000 18:18:45 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Why won't  "use strict;"  work?
Message-Id: <23637-397CCED5-116@storefull-242.iap.bryant.webtv.net>

Thanks Tad, Abigail, and others. I picked up on Abigail's phrase
"lexical global," so I did some more research on "my" and "local", and
figured out that I should be using "my $"... I just can't figure out
how, where, etc. to use "my". Sigh.

I just hope that I don't have to add all of those STDIN STDOUT $ENV,
etc. things too. This is getting so complicated. Maybe I'm misunderstand
perl(it's probably too difficult for me), but it seems to me that perl
is written in a code-intensive "pyramid" fashion, meaning, everything
needs something else to be defined, and that, in turn needs something
defined, etc, etc., and that you never get done writing the code. Maybe
I'm exaggerating, but I hope you don't have to learn every code in that
12,000 pages in order to accomplish just a few simple tasks. :-)

And is the perl coding that I use dependent upon my webserver or my PC?
For example: I've read that Unix supports the flock command, but that
Windows doesn't. I use a webserver that runs Unix, and use Winblows 98
on my PC. Does that mean that my flock code that is input on my
webserver will be supported, and that I can click on it from my Win98
OS, and it will work correctly? 

I've been using the perl man page at
http://cpan.org/doc/manual/html/pod/perl.html along with a similar one
at about.com, and some others. Of course, I haven't read all 12,000
pages... but I have read a few hundred pages.

I have no intentions of trying to become a professional perl programmer.
I would like to learn how to accurately do this counter coding,
though... and then I want to write a search and replace page... and then
a multiple directory mover. The last program is so I can upload multiple
directories on WebTV, since I can't use WS_ FTP as I do on my PC. Wish I
knew how to write a perl emulator of WS FTP_LE with all of the
functions?

Who knows where my coding urge may stop? ... but for now, I have spent
way too much time on this counter, and can't even get IT done correctly.
I thought a "counter" would be easier. FWIW, I was going to do my Search
and Replace next, but it looks like a directory uploader would be
easier?

Anyway, enough rambling. What do I change "truncate(COUNT, 0) to? Do I
even need to use "truncate" since I don't always know the length of the
counter? meaning, I wan't to allow the counter to go from 9,999 to
10,000 without having to change any coding, if I ever get it right.

Still confused and praying it gets easier,
Dennis



------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 3791
**************************************


home help back first fref pref prev next nref lref last post