[6335] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 957 Volume: 7

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 15 21:17:21 1997

Date: Sat, 15 Feb 97 18:00:19 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 15 Feb 1997     Volume: 7 Number: 957

Today's topics:
     Re: "scalar each"  - what does it mean? <merlyn@stonehenge.com>
     Re: CGI.pm dynamic tables? (Lincoln Stein)
     Comparing two dates basj@cyber.xs4all.nl
     Re: Comparing two dates (Nathan V. Patwardhan)
     Re: compiling perl <Webmaster@tarrcity.demon.co.uk>
     Re: Counting values within a file (Ken Williams)
     Re: difference btw s/// & tr/// <fkong@scf.usc.edu>
     Need help generating tree for site <jmp@pi.net>
     Re: Need help generating tree for site (Nathan V. Patwardhan)
     overwriting in-memory password ("Thomas A. Fine")
     Re: overwriting in-memory password (Nathan V. Patwardhan)
     Passing parameters <brian@shepmark.com>
     Re: Passing parameters (Nathan V. Patwardhan)
     Re: Passing parameters (Clay Irving)
     Perl Sockets reprise msosteri@yesic.com
     playing w/the $`,$&, and &' vars <pirwani@blue.weeg.uiowa.edu>
     Re: Reading files in a directory and printing to one tx (Vasudev Dalal)
     Re: Regexp to do minimal email validation <tchrist@mox.perl.com>
     Re: Regexp to do minimal email validation <merlyn@stonehenge.com>
     Some Socket Questions msosteri@yesic.com
     Where can I find code samples. <trobison@erols.com>
     Re: Where can I find code samples. <otisg@panther.middlebury.edu>
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: 15 Feb 1997 14:49:26 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Brett McCormick <brett@speedy.speakeasy.org>
Subject: Re: "scalar each"  - what does it mean?
Message-Id: <8c7mk9oi3d.fsf@gadget.cscaper.com>

>>>>> "Brett" == Brett McCormick <brett@speedy.speakeasy.org> writes:

Brett> Tom Christiansen <tchrist@mox.perl.com> writes:

>> 
>> There is a logic error there:
>> 
>> 1 each returns a list of two elements
>> 2 when you evaluate a list as a scalar, you get its count
>> (actually, you usually get the last element of the
>> list; it's an array that gives you its count)
>> 3 therefore each as a scalar is its count

Brett> Hmmm, interesting..  I was unaware that there was a difference between
Brett> arrays and lists..  I assume that a list is one or more perl types,
Brett> where as an array is a perl type (which happens to contain 0 or more
Brett> other perl types?_

You seem to be digging yourself a deeper grave.  Here's some factoids
that may clear it up:

An array variable holds a list value.

Any construct in Perl can be given an arbitrary "list value" and
"scalar value".  The "list value" will be used in a list context,
and the "scalar value" will be used in a scalar context.

*Some* of the constructs that return a list in a list context also
happen to return the length of that list in a scalar value.  For
example, the construct @a in a list context returns the contents of
@a, but in a scalar context, returns the length of that array.

However, the construct ($a,$b,$c) in a list context returns a 3
element list, but in a scalar context returns $c!

Another example, sort() returns the sorted list in a list context,
but *undef* in a scalar context.

Still another example, getpwnam() returns a nine-element list from the
password database in a list context, and the *third* element of that
list (the uid number) in a scalar context.

As a bizarre example, the "scalar each" operator could in fact, be
made to invoke Nethack instead of returning anything in particular.
In other words, IT'S TOTALLY ARBITRARY what they return in a scalar
context vs. a list context!  It's whatever Larry designed it to do.
That's why you can't expect it to return "2", or the "first element"
or anything.  If it's not documented, you just *can't tell*.

As it turns out, "scalar each" returns just each key, one at a time.
Interesting, somewhat intuitive, but clearly undocumented at least in
the manpages that made up the new blue camel.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 562 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 15 Feb 1997 21:31:54 GMT
From: lstein@logo (Lincoln Stein)
Subject: Re: CGI.pm dynamic tables?
Message-Id: <5e5a0a$dit@senator-bedfellow.MIT.EDU>

In article <wjkohdyn8q2.fsf@bitsrfr.cnd.hp.com>,
Jacob Miner <jacob@bitsrfr.cnd.hp.com> wrote:
>    Is there any way to create a dynamic table using the CGI.pm
>module, and it's syntax?

>    print table(
>                Tr(
>                    foreach $entry ('one','two') {
>                    td("entry");
>                    }
>                   )
>               )

Try something like this:

	foreach $entry ('one','two') {
		push(@cells,td($entry));
	}
	print table(Tr(@cells));

Lincoln



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

Date: Sun, 16 Feb 1997 00:15:38 -0800
From: basj@cyber.xs4all.nl
Subject: Comparing two dates
Message-Id: <3306C22A.794B@cyber.xs4all.nl>

Hi--

I want to create a 'what's new' page on my webserver. I have a list of
all HTML documents with their dates in a file. I get the date that a
user has visited my webserver for the last time from a magic-cookie. How
can I compare the two dates so that I can fill an array with new
documents since the user's last visit. Is store the two dates in the
following format: Sat Feb 15 23:11:21 PST 1997

Is there a function for this or will I have to split the dates in
components and compater them individually (hope not) ?


-- 
basj@cyber.xs4all.nl
PGP 2.6.3i KeyID 7010044D    / -- I'm Powered By Silicon Graphics -- /
http://www.xs4all.nl/~basj


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

Date: 16 Feb 1997 01:27:06 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Comparing two dates
Message-Id: <5e5npa$bbp@fridge-nf0.shore.net>

basj@cyber.xs4all.nl wrote:


: Is there a function for this or will I have to split the dates in
: components and compater them individually (hope not) ?

I don't see what's wrong with using localtime().  :-)  It's not very 
difficult to split the time into hours, minutes, and seconds, then compare
the result with another entry.

HTH!

--
Nathan V. Patwardhan
nvp@shore.net
"send me mail"
	--Jamie Zawinski


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

Date: Sat, 15 Feb 1997 23:08:20 +0000
From: Webmaster <Webmaster@tarrcity.demon.co.uk>
Subject: Re: compiling perl
Message-Id: <RvAr0GAkHkBzEwcl@tarrcity.demon.co.uk>

In article <330227F9.14F3@everyday.no>, Morten Kristiansen
<Morten@everyday.no> writes
>The problem I originally have, is that I have a cgi script written in
>Perl, and when I set the permissions to --x--x--x, it wont execute. I
>have to set the permissions to r-xr-xr-x to make it execute. The problem
>then is that the script can be read by anyone, and I don't want that.

I'm new to perl & just lurking at present but this looks like a unix
permissions problem rather than a perl one.  The user executing perl has
to be able to read the script - hence the need for the read permissions.

You might try setting the uid on the perl executable and making the
script readable by owner only, owner of the script being the same as the
owner of the perl executable.

>Does anyone have any suggestions or other ways to resolve my original
>problem (running a perl-cgi script that can't be read by anyone).

I'd suggest that you'll need to make it readable by *someone* (like the
owner of the script) but not by group and other.

HTH

-- 
Wm ... 


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

Date: Sat, 15 Feb 1997 16:23:55 -0500
From: ken@forum.swarthmore.edu (Ken Williams)
Subject: Re: Counting values within a file
Message-Id: <ken-1502971623550001@news.swarthmore.edu>

In article <JGRABER.97Feb14163705@sun_7407>, jgraber@daldd.sc.ti.com wrote:

I hate to talk too much about Unix on a Perl newsgroup, but I do want to
respond...

> > This isn't a Perl solution, but this has always been one of my favorite
> > tricks in Unix:
> > 
> > cat filename | sort | uniq -c
> > 
> > That will do what you need, I think, and faster than the Perl equivalent.
> 

> sort filename | uniq -c   # does the same without the useless cat.

Right.  My mistake.


> 
> But picking additional nits, it does not solve the stated problem either.
> Your solution does not "append text underneath this" 
> which would require using another cat and some text "Total ==== etc".

Why would you need another cat?  What's wrong with 
  sort filename | uniq -c >> filename   
  ?

The only problem with that is that it doesn't stick in a line between the
original file and the counting statistics.  But you could fix that on the
Unix line too, if you wanted to.  You could also fix the order of the
columns pretty easily if you wanted to.  Personally, I wouldn't want to. 
I'd use Perl.

The reason I posted in the first place was just that I thought it was a
neat trick.  I'm not about to hang up my Perl hat and start wearing a
Shell Script one.

-Ken Williams
 ken@forum.swarthmore.edu


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

Date: 15 Feb 1997 13:58:12 -0800
From: Elton Kong <fkong@scf.usc.edu>
Subject: Re: difference btw s/// & tr///
Message-Id: <Pine.SV4.3.94.970215135245.4098A-100000@koh-sun7.usc.edu>

Thanks for the replies! In fact I have looked into the perlop and perlre
manual pages, and (I think) I know perfectly well the difference between
the 2 operators. I just wonder when both can be used, which one is more
efficient?

You see, below is my problem. I have an input file with a certain
character which I want to get rid of. So I can use either of the forms
below.

s/\cM//g;
tr/\cM//d;

Thus my question is: which is more efficient?

BTW, is there any difference if I don't put a "g" after the s/// opeator?
I can't see the difference after trying.

Thanks.

Elton
--
Elton Kong
mailto:fkong@scf.usc.edu
http://www-scf.usc.edu/~fkong/



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

Date: Sun, 16 Feb 1997 00:10:20 GMT
From: "Jon Petersen" <jmp@pi.net>
Subject: Need help generating tree for site
Message-Id: <01bc0aad$877764e0$46c2dc91@JonP>

I want to generate a tree (structure), by extracting/following the HREF's
in > 100 HTML sources.
Does anyone know if there's a PERL script for doing so.

thanks 

Jon jmp@pi.net


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

Date: 16 Feb 1997 01:21:48 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Need help generating tree for site
Message-Id: <5e5nfc$bbp@fridge-nf0.shore.net>

Jon Petersen (jmp@pi.net) wrote:
: I want to generate a tree (structure), by extracting/following the HREF's
: in > 100 HTML sources.
: Does anyone know if there's a PERL script for doing so.

Check http://www.dejanews.com for the comp.lang.perl.misc archives.  Someone
described matching HREFs a couple of days/about a week ago.

--
Nathan V. Patwardhan
nvp@shore.net
"send me mail"
	--Jamie Zawinski


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

Date: 16 Feb 1997 01:13:14 GMT
From: fine@net.ohio-state.edu ("Thomas A. Fine")
Subject: overwriting in-memory password
Message-Id: <5e5mva$otv@charm.magnus.acs.ohio-state.edu>

I'm writing a program that will be dealing with passwords, and running
continuously.  I don't want it to keep the passwords in memory any longer
than necessary.  What's the correct way to _guarantee_ that I've removed
it from memory after use?

     tom


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

Date: 16 Feb 1997 01:24:35 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: overwriting in-memory password
Message-Id: <5e5nkj$bbp@fridge-nf0.shore.net>

Thomas A. Fine (fine@net.ohio-state.edu) wrote:
: than necessary.  What's the correct way to _guarantee_ that I've removed
: it from memory after use?

undef $varname;

--
Nathan V. Patwardhan
nvp@shore.net
"send me mail"
	--Jamie Zawinski


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

Date: 15 Feb 1997 20:07:41 GMT
From: "Brian Shepard" <brian@shepmark.com>
Subject: Passing parameters
Message-Id: <01bc1b84$c6c89b40$dc52b5cf@default>

I have a quick question. How would I send my perl script a parameter
without using a form.

i.e. I want to have a link like this <A HREF="search.pl"> from my HTML code
and I want to tell the Perl script that I'm calling to search for computers

Question 1 how do I set up my HTML code?

Question 2 What do I have to do in my Perl code to accept the parameter
sent to it?


Any help would be greatly appreciated.

Thanks



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

Date: 15 Feb 1997 20:24:33 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Passing parameters
Message-Id: <5e5621$mdh@fridge-nf0.shore.net>

Brian Shepard (brian@shepmark.com) wrote:
: I have a quick question. How would I send my perl script a parameter

: Question 1 how do I set up my HTML code?

HTML is not code - it's markup.

: Question 2 What do I have to do in my Perl code to accept the parameter
: sent to it?

The environment variable you're looking for is QUERY_STRING, which is
discussed in comp.infosystems.www.authoring.cgi, and appears in most
books dealing with CGI programming.

HTH!

--
Nathan V. Patwardhan
nvp@shore.net
"send me mail"
	--Jamie Zawinski


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

Date: 15 Feb 1997 16:53:36 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Passing parameters
Message-Id: <5e5b90$ffg@panix.com>

In <01bc1b84$c6c89b40$dc52b5cf@default> "Brian Shepard" <brian@shepmark.com> writes:

>I have a quick question. How would I send my perl script a parameter
>without using a form.

What's a "form?"

>i.e. I want to have a link like this <A HREF="search.pl"> from my HTML code
>and I want to tell the Perl script that I'm calling to search for computers

A form on the Web!

>Question 1 how do I set up my HTML code?

HTML? This is a newgroup about Perl.

>Question 2 What do I have to do in my Perl code to accept the parameter
>sent to it?

Er... Write a program?

precog(question_2);

What have you done so far? Maybe your problem is how to parse the variables?
I don't know. Post a specific question or the code, and you stand a very
high chance of gettin at least one answer!

-- 
See the happy moron,                             
He doesn't give a damn,                                    Clay Irving N2VKG  
I wish I were a moron,                                        clay@panix.com
My God! Perhaps I am!                             http://www.panix.com/~clay


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

Date: Sat, 15 Feb 1997 13:31:12 -0600
From: msosteri@yesic.com
Subject: Perl Sockets reprise
Message-Id: <856034733.19165@dejanews.com>

Oops, I forgot in my last post for information. After binding and
listening on the data socket, there is this use of select

select(     (    select(SOCKET), $| = 1        )[0]       );

which I can't make hide nor hair of. I know what the two versions of
select do, and I known about turning of bufferning with $|. But the
construct above completely baffles me. What's equally puzzling is a
simple select in this situation won't work so there must be something
special about this cryptic use of select.

thanks

mike

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Sat, 15 Feb 1997 19:32:42 -0600
From: Lyle <pirwani@blue.weeg.uiowa.edu>
Subject: playing w/the $`,$&, and &' vars
Message-Id: <Pine.A41.3.95.970215191843.102550A-100000@green.weeg.uiowa.edu>


Hi!  I've been working on a script to fix parenthesis usage in ascii
text.  Bascically what I want to do is insert a single space after every
occurance of a ( on a line, and insert a space before every occurance of )
on a line.
______________________________________________________________________
#!/local/software/bin/perl

while($file = shift) {
  $newfile = $file . ".pretty";
  open(OFILE,"$file") || warn "can't $!";
  open(NFILE,">$newfile") || warn "can't $!";

  while(<OFILE>) {
    next unless /\(|\)/; #only process lines with ( or )
    s/\(/$& /g;
    s/\)/ $&/g;
    print NFILE "$_";
  }
  close(OFILE);
  close(NFILE);    

} 

________________________________________________________________

This works fine until it encounters a line like
(      text     )
which it turns into
(       text     ).
  
What I'd like to do is chop up the $' var and insert it back into the
string, ie

  $' =~ s/(\s+)\b//;

and then append the new $' back in.  Unfortuantely the $' is read only!
Besides, since I substitute all the ('s and )'s globally, this method
would only work for the last located ( ...

Can anyone give me a suggestion here?  
Thanks!
--Lyle



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

Date: 15 Feb 1997 23:03:29 GMT
From: vkd0871@omega.uta.edu (Vasudev Dalal)
Subject: Re: Reading files in a directory and printing to one txt file
Message-Id: <5e5fc1$3go@news.uta.edu>

Hello :

mohawk@swceweb.com wrote:
: I'm completely new at this and am trying to create a script to read a
: bunch of files in a directory and output them to one txt file.

Sure. Use OPENDIR and READDIR commands.
Look at some standard reference. Its really simple.
Get back to this Group if u have any problems.
A standard reference would be :
1) Learning Perl (the Llama Book):
             ISBN 1-56592-042-2      (English)
	     O'Reilly Associates
	     Randal S. 

: What it's for is a classroom type thing where a chat room is set up as a
: class and I need a transcript of the session, getting just the message
: and the username.
: Can I get some advice as to how to proceed with this? 

I don't know what u r talking about.

Vasu


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

Date: 15 Feb 1997 23:39:56 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Regexp to do minimal email validation
Message-Id: <5e5hgc$bh6$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    jsd@gamespot.com writes:
:say i want to do a quick'n'dirty check to see if an email address
:matches user@somewhere.com or user@some.where.com or
:user@ab.cd.ef.fg.fhg.com...
:
:the best i could come up with was:
:
:/^\w+@[a-z0-9][\w\.]+/

Really?  This was the best I (with jfriedl help) could come up with :-)

#!/usr/bin/perl
#
# addrcheck - mail address checker
# by tchrist@perl.com
# Copyright 1997 Tom Christiansen
# version 1.001 Fri Feb 14 15:20:02 MST 1997

####################################
# this program takes an email address as its argument
# and decides whether you're being spoofed or not.
# it exists 0 if it likes the address, and 1 if it doesn't.
# 
# can be tested interactively.  if not interactive, it will
# use syslog.
#
# should be rewritten instead of just growing via hacks.
####################################

$LOGGER   = '/usr/bin/logger';  # or /usr/ucb?
$NSLOOKUP = '/usr/bin/nslookup';  # or /usr/ucb?

$DEBUG = -t STDIN && -t STDOUT;
$address = shift || die "usage: $0 address\n";

for ($address) {
    s/^-+//;
    tr/A-Z/a-z/;
}

($user, $host) = split /\@/, $address;

# we check in this order because of speed;
# this way it will fail more quickly.

check_passwd($user);	# picky

# maybe de-comment the next line for ftp checks
# if ($address =~ /\@./) 
{ 
    check_host($host);
    ck822($address);   	# inscrutable
    dns_check($host);  	# slow
}

exit 0;

####################################
 
sub bad {
    # GLOBAL $hispass and $what
    if ($DEBUG) {
	print "$what `$hispass' is bad: @_\n";
    } else {
	system $LOGGER,
		    "-p", "daemon.notice", 
		    "-t", "ftpucheck",
		"BOGUS \U$what\E $hispass (@_)";
    } 
    exit 1;
} 

####################################

#############

sub check_passwd {  
    local $what = 'user';
    local $hispass = shift;

    for (@rude) {
	bad("rude") if index($hispass, lc $_) != -1;
    } 

    for (@anywhere) {
	bad("inside") if index($hispass, lc $_) != -1;
    } 

    for (@full) {
	bad("full") if $hispass eq lc $_;
    } 

    for (@start) {
	bad("start") if index($hispass, lc $_) == 0;
    } 

    # single char
    bad("single") if length($hispass) == 1;

    study $hispass;

    bad("dup letters") if $hispass =~ /(\w)\1{3,}/;

    bad("white") if $hispass =~ /\s/;

    bad("junk") if $hispass =~ /[;,\/#^*]/;

    $V = 'aeiouy';
    if ($hispass =~ /netscape/ || $hispass =~ /^m[$V]*[sz]+[$V]*l+[$V]*\W*$/) {
	bad("mozilla");
    } 

    if ($hispass =~ /xyz+y/) {
	bad("xyzzy");
    } 

    # all same letter
    bad("dup letters") if $hispass =~ /^(.)\1+$/;

    # want letters
    bad("ugly") unless $hispass =~ /[a-z]/;

    bad("backspace") if $hispass =~ /[\010\177]/;

    $letters = "qwertyuiopasdfghjklzxcvbnmmnbvcxzlkjhgfrdsapoiuytrewq";

    # consecutive
    bad("consecutive") if 
	    length($hispass) > 2 &&
		( index($letters, $hispass) != -1
		    ||
		  ($hispass =~ /^(\w+)\1$/ && length($1) > 2
		    && index($letters, $1) != -1)
		);

    print "$what: $hispass is good\n" if $DEBUG;

}


#############

sub check_host {
    local $what = 'host';
    local $hispass = shift;

    bad("dotless") unless index($hispass, '.') >= 0;

    for (@rude) {
	bad("rude") if index($hispass, lc $_) != -1;
    } 

    for (@full) {
	bad("full") if $hispass eq lc $_;
    } 

    # single char
    bad("single") if length($hispass) == 1;

    study $hispass;

    bad("white") if $hispass =~ /\s/;

    bad("junk") if $hispass =~ /[;,\/#^*]/;

    # want letters, darnit;  this will cause 127.1 to fail though
    bad("ugly") unless $hispass =~ /[a-z]/;

    bad("backspace") if $hispass =~ /[\010\177]/;

    $letters = "qwertyuiopasdfghjklzxcvbnmmnbvcxzlkjhgfrdsapoiuytrewq";

    # consecutive
    bad("consecutive") if 
	    length($hispass) > 2 &&
		( index($letters, $hispass) != -1
		    ||
		  ($hispass =~ /^(\w+)\1$/ && length($1) > 2
		    && index($letters, $1) != -1)
		);

    print "$what: $hispass is good\n" if $DEBUG;

}

sub dns_check {
    # first try an MX record, then an A rec (for badly configged hosts)

    my $host = shift;
    local $/ = undef;
    local $what = "DNS record";
    local $hispass = $host;


    # the following is comment out for security reasons:
    #	if ( `nslookup -query=mx $host` =~ /mail exchanger/
    # otherwise there could be naughty bits in $host
    # we'll bypass system() and get right at execvp()

    if (open(NS, "-|")) {
	if (<NS> =~ /mail exchanger/) {
	    print "$what MX: $hispass is good\n" if $DEBUG;
	    close NS;
	    return;
	}
    } else {
	open(SE, ">&STDERR");
	open(STDERR, ">/dev/null");
	exec $NSLOOKUP, '-query=mx', $host;
	open(STDERR, ">&SE");
	die "can't exec nslookup: $!";
    } 

    if (open(NS, "-|")) {
	if (<NS> =~ /answer:.*Address/s) {
	    print "$what A: $hispass is good\n" if $DEBUG;
	    close NS;
	    return;
	}
    } else {
	open(SE, ">&STDERR");
	open(STDERR, ">/dev/null");
	exec $NSLOOKUP, '-query=a', $host;
	open(STDERR, ">&SE");
	die "can't exec nslookup: $!";
    } 

    bad("No DNS");
} 


sub ck822 { 

    # ck822 -- check whether address is valid rfc 822 address
    # tchrist@perl.com
    #
    # pattern developed in program by jfriedl; 
    # see "Mastering Regular Expressions" from ORA for details

    # this will error on something like "ftp.perl.com." because
    # even though dns wants it, rfc822 hates it.  shucks.

    local $what = 'address';

    local $hispass = shift;
    local $_;

    $is_a_valid_rfc_822_addr = '';

    while (<DATA>) {
	chomp;
	$is_a_valid_rfc_822_addr .= $_;
    } 


    bad("rfc822 failure") unless $hispass =~ /^${is_a_valid_rfc_822_addr}$/o;
    print "$what: $hispass is good\n" if $DEBUG;
}

##############################
# initializations
##############################

BEGIN {

    @full = qw{

	admin
	anon
	anonymous
	bar
	big-liar
	bin
	bizarre
	bla
	blah
	bogus
	bummy
	cache
	collect
	compuserve
	cool
	crud
	DeleGateMaster
	devnull
	dialup
	dork
	dummy
	dunno
	employee
	first1
	foo
	friendly
	ftpsearch-collect
	fu
	god
	guest
	gunk
	gw
	harvest
	here
	hi
	ident
	ident
	ie30user
	info
	informix
	internet
	junk
	liar
	login
	lycos
	maxima
	me
	mirror
	mosaic
	nobody
	none
	none-known
	nouser
	ntcon
	ok
	outbound
	postmaster
	president
	public
	Put_Your_Email_Address
	report_abuse
	root
	satan
	socks
	spanky
	src
	sticky
	system
	there
	unknown
	Unknown_Netscape_User
	Unregistered
	unverified
	user
	UserName
	vice-president
	vividnet
	whoever
	WinGate
	wow
	xyz
	xyz

    };

    @start = qw{

	aaa
	abc
	account
	anon
	anon
	asquid
	daemon 
	delegate
	ftp
	gopher
	gotch
	oracle
	otthttp
	pass
	satan
	squid
	student
	test
	web
	xx

    };

    @anywhere = qw{

	adresse
	asdf
	address
	asfd
	cache
	firewall
	-gw
	http
	mail
	mirror
	mother
	name
	nobody
	proxy
	sadf
	system
	user
	www

    }; 

    @rude = qw{

	asshole
	crap
	cunt
	damn
	fuck
	piss
	shit
	suck
	tits
	upyour

    };

}

# don't touch this stuff down here or you'll break the rfc822 matcher.
__END__
(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n
\015()]|\\[^\x80-\xff])*\))*\))*(?:(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\
xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"(?:[^\\\x80-\xff\n\015"
]|\\[^\x80-\xff])*")(?:(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xf
f]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*\.(?:[\040\t]|\((?:[
^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\
xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;
:".\\\[\]\000-\037\x80-\xff])|"(?:[^\\\x80-\xff\n\015"]|\\[^\x80-\xff])*"))
*(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\
n\015()]|\\[^\x80-\xff])*\))*\))*@(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\
\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\04
0)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-
\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])(?:(?:[\040\t]|\((?
:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80
-\xff])*\))*\))*\.(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\(
(?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]
\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\
\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\]))*|(?:[^(\040)<>@,;:".\\\[\]\000-\0
37\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"(?:[^\\\x80-\xf
f\n\015"]|\\[^\x80-\xff])*")(?:[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\03
7]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\
\[^\x80-\xff])*\))*\)|"(?:[^\\\x80-\xff\n\015"]|\\[^\x80-\xff])*")*<(?:[\04
0\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]
|\\[^\x80-\xff])*\))*\))*(?:@(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x
80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@
,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]
)|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])(?:(?:[\040\t]|\((?:[^\\
\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff
])*\))*\))*\.(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^
\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]\000-
\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-
\xff\n\015\[\]]|\\[^\x80-\xff])*\]))*(?:(?:[\040\t]|\((?:[^\\\x80-\xff\n\01
5()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*,(?
:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\0
15()]|\\[^\x80-\xff])*\))*\))*@(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^
\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<
>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xf
f])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])(?:(?:[\040\t]|\((?:[^
\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\x
ff])*\))*\))*\.(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:
[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]\00
0-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x8
0-\xff\n\015\[\]]|\\[^\x80-\xff])*\]))*)*:(?:[\040\t]|\((?:[^\\\x80-\xff\n\
015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*)
?(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000
-\037\x80-\xff])|"(?:[^\\\x80-\xff\n\015"]|\\[^\x80-\xff])*")(?:(?:[\040\t]
|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[
^\x80-\xff])*\))*\))*\.(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xf
f]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@,;:".\
\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"(?:
[^\\\x80-\xff\n\015"]|\\[^\x80-\xff])*"))*(?:[\040\t]|\((?:[^\\\x80-\xff\n\
015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*@
(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n
\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff
]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\
]]|\\[^\x80-\xff])*\])(?:(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\
xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*\.(?:[\040\t]|\((?
:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80
-\xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@
,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff
])*\]))*(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x8
0-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*>)(?:[\040\t]|\((?:[^\\\x80-\xff\n\
015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*


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

Date: 15 Feb 1997 18:24:50 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: jsd@gamespot.com
Subject: Re: Regexp to do minimal email validation
Message-Id: <8clo8pmtjx.fsf@gadget.cscaper.com>

>>>>> "Jon" == Jon Drukman <jsd@cyborganic.com> writes:

Jon> say i want to do a quick'n'dirty check to see if an email address
Jon> matches user@somewhere.com or user@some.where.com or
Jon> user@ab.cd.ef.fg.fhg.com...

Say I wanted to do a quick'n'dirty check to see if this question
doesn't already get asked and answered about every 15 minutes on the
newsgroups already.  I'd probably visit www.dejanews.com or
www.altavista.com and ask "validate & email & address" or somesuch.

Yeah, that's probably what I would do.

Jon> the best i could come up with was:

Jon> /^\w+@[a-z0-9][\w\.]+/

<Bzzzt!>  Wrong.

The really short answer, if you are really lazy, is that you just
*can't*.  You can't.  There's no point.  Send the mail, and if it gets
to them, it's the right address.  <fred&barney@stonehenge.com> is a
valid address, and would have been falsely rejected by your regexp.
Really.  Go ahead and send to it... you'll get an autoreply. (I just
set that up <grin>.)  Nearly *any* character is allowed in the local
part (to the left of the @).

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 562 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Sat, 15 Feb 1997 13:21:20 -0600
From: msosteri@yesic.com
Subject: Some Socket Questions
Message-Id: <856034409.18909@dejanews.com>

Okay, the last frontier of learning perl for me is to program sockets.
Besides the fact that I'm stuck using Windows 95, uugh, I have a couple o
questions.

I'm using Tom's C's (can't remember the spelling) ftp.pm to learn about
sockets. I'm about half way through creating a data connection (I have
succedded in getting the program to do regular commands, and can't figure
out these commands.

the data connection appears to be created at port 0.

pack($Sockaddr, 2, 0, "\0\0\0\0");

Am I missing something here?

When you send the port command, you send a hostaddress and a port number.
Tom unpacks his previous pack to get $port and $address ($address is 0000
in this case cause I'm using windows and can't get a host address) and
then says.

             push(@myaddr, $port >> 8, $port & 0xff);

and then

port @myaddress.

Can anyone tell me what's going on here?????

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 15 Feb 1997 22:50:57 GMT
From: "Terry Robison" <trobison@erols.com>
Subject: Where can I find code samples.
Message-Id: <01bc1b92$3f92ed20$e86aaccf@trobison>

I am just starting to write perl scripts and would like to look at some
sample code. Where can I find some? My first task is to read a binary file
and print it to an ASCI file. I have the Camel Book but some samples would
help.  Thanks in advance...

Terry Robison
trobison@erols.com



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

Date: 16 Feb 1997 00:55:29 GMT
From: "Otis Gospodnetic" <otisg@panther.middlebury.edu>
Subject: Re: Where can I find code samples.
Message-Id: <01bc1ba4$300bd6c0$add1e98c@ns.middlebury.edu>

I would try http://www.perl.com/ or http://www.perl.org/ or try looking for
a Perl Journal at http://www.dominis.com/Zines/

good luck

Otis
-- 
====================================================================
POPULUS, The People Locator - The Intelligent White Pages -
http://www.POPULUS.net/
====================================================================

Terry Robison <trobison@erols.com> wrote in article
<01bc1b92$3f92ed20$e86aaccf@trobison>...
> I am just starting to write perl scripts and would like to look at some
> sample code. Where can I find some? My first task is to read a binary
file
> and print it to an ASCI file. I have the Camel Book but some samples
would
> help.  Thanks in advance...
> 
> Terry Robison
> trobison@erols.com
> 
> 


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

Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Jan 97)
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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

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 V7 Issue 957
*************************************

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