[19661] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1856 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 2 14:06:09 2001

Date: Tue, 2 Oct 2001 11:05:11 -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: <1002045910-v10-i1856@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 2 Oct 2001     Volume: 10 Number: 1856

Today's topics:
    Re: 2 newlines after Headerlines in HTTP? (Rafael Garcia-Suarez)
    Re: Algorithm/Module for improving poor RegExps? <nospam-abuse@ilyaz.org>
        bad math or code <jamie_bohr@agilent.com>
    Re: bad math or code <jurgenex@hotmail.com>
    Re: bad math or code (John J. Trammell)
    Re: Conditional regex substitution <eod_spam@yahoo.es>
    Re: Conditional regex substitution nobull@mail.com
        Efficient code? <s.warhurst@rl.ac.uk>
    Re: Embed Sound into cgi? <casey1@adelphia.net>
    Re: Embed Sound into cgi? <Thomas@Baetzler.de>
    Re: Embed Sound into cgi? <casey1@adelphia.net>
    Re: GIF encoding <nobody@nowhere.com>
    Re: how to get rid of spaces around a string? <darkon@one.net>
    Re: how to send mail without sendmail <JPFauvelle@Colt-Telecom.fr>
    Re: how to send mail without sendmail <JPFauvelle@Colt-Telecom.fr>
        identifying bogus email address formats <a0197620@MailAndNews.com>
    Re: identifying bogus email address formats (Randal L. Schwartz)
        IE user jamming the Stop button while Perl/IIS processi (Kevin Ketchum)
    Re: Installing a Module in my own directory?? <Graham.T.Wood@oracle.com>
        MacPerl newbie question (Patrik Nyman)
    Re: Passing arguments to subs <darkon@one.net>
    Re: Passing arguments to subs <mbudash@sonic.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 2 Oct 2001 13:07:59 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: 2 newlines after Headerlines in HTTP?
Message-Id: <slrn9rjf0v.71e.rgarciasuarez@rafael.kazibao.net>

Rainer Klier wrote in comp.lang.perl.misc:
} 
} to make visible, what a browser sends to a webserver,
} I coded this tiny webserver, that shall bounce the
} Requestheader back to the Browser.
} Interesstingly it says, that the browser sent
} 2 newlines after the headerrequest. RFC 2616 says,
} there should be one newline. Did I miss something?

Yes, there's an empty line for the body of the request sent by the
browser. Have you tried with a POST instead of a GET?

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
$japh="Just another Perl hacker,\n";@j=split/(?= )/,$japh;for my $i
(0..3){*{(($x)=$j[3-$i]=~/\w+/g)[0]}=sub(@){print$j[$i]}}eval$japh;


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

Date: Tue, 2 Oct 2001 13:21:13 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Algorithm/Module for improving poor RegExps?
Message-Id: <9pcf09$duh$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Mark Jason Dominus
<mjd@plover.com>], who wrote in article <3bb9b699.54ad$1df@news.op.net>:
> >Why not just do
> >
> >    s/(?:tree|fee|gee)/x/
> >
> >and let Perl's regexp compiler optimize things?  
> 
> It doesn't perform the 'optimization' you are asking for.
> 
> Nor should it, since it would make the regex slower.

a) there is no such word;

b) the substibution would make the REx orders of magnitude quickier.

> >It should combine them into a single state machine and the 'ee's
> >would get put together into a single state (or two).
> 
> It should not.  (?:tr|f|g)ee has four states for 'tr', 'f', 'g', and
> 'ee', plus some for the |'s.  (?:tree|fee|gee) has three states for
> 'tree', 'fee', and 'gee', plus the same states for the |'s.  Also,
> since the target strings are longer, the Boyer-Moore search is likely
> to produce fewer false positives.

BMF is not performed unless there is a constant substring (as there is
with the merged version).  Number of "states" (I do not know what it
is) has no relation to the speed.

Hope this helps,
Ilya


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

Date: Tue, 2 Oct 2001 09:54:22 -0600
From: "Jamie R. Bohr" <jamie_bohr@agilent.com>
Subject: bad math or code
Message-Id: <1002038016.228570@goodnews.cos.agilent.com>

It is really wierd that 3.50 - 3.48 does not equal 0.02 in perl, for example
please look at the code below:

$A="3.50";
$B="3.48";
$C="2";

if((($A - $B) * 100) > $C) {
  printf("A - B > C\n");
  printf("%s > %s\n", (($A - $B) * 100) , $C);
} else {
  print "A - B !> C\n";
}


When I run the above code I get:

A - B > C
2 > 2

When is 2 greater than 2?  All my perl books are at work and I have not
found any thing on line that helps.







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

Date: Tue, 2 Oct 2001 09:14:48 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: bad math or code
Message-Id: <3bb9e7f9$1@news.microsoft.com>

"Jamie R. Bohr" <jamie_bohr@agilent.com> wrote in message
news:1002038016.228570@goodnews.cos.agilent.com...
> It is really wierd that 3.50 - 3.48 does not equal 0.02 in perl, for
example
> please look at the code below:

Well, no, it's not wierd at all. You forgot the first law of numerics:

    Thou shalt not use floating point for precise computations

It would be rather surprising if Perl would do accurate floating point
arithmetic.
You may want to read up on numerical computation and why it is impossible
(well, at least on standard computers with standard tools) to get accurate
computations with floating point numbers.

Hint: the solution is to use natural numbers, or to check against an epsilon
environment (instead of equality), or to use a special math packet.

jue






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

Date: Tue, 2 Oct 2001 11:19:13 -0500
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: bad math or code
Message-Id: <slrn9rjq81.kq.trammell@haqq.hypersloth.net>

On Tue, 2 Oct 2001 09:54:22 -0600, Jamie R. Bohr <jamie_bohr@agilent.com> wrote:
> It is really wierd that 3.50 - 3.48 does not equal 0.02 in perl, for example
> please look at the code below:
> 
> $A="3.50";
> $B="3.48";
> $C="2";
> 
> if((($A - $B) * 100) > $C) {
>   printf("A - B > C\n");
>   printf("%s > %s\n", (($A - $B) * 100) , $C);
> } else {
>   print "A - B !> C\n";
> }
> 

[ ~ ] cat -n foo 
     1  my $a = 3.50;
     2  my $b = 3.48;
     3  my $c = 2;
     4  my $d = ($a - $b) * 100;
     5
     6  if ($d > $c)
     7  {
     8      print "A - B > C\n";
     9      printf("%f > %f\n",$d,$c);
    10  }
    11
    12  if (sprintf("%d",$c) eq sprintf("%d",$d))
    13  {
    14      print "A - B == C, when done correctly!\n";
    15  }
    16
    17
[ ~ ] perl foo 
A - B > C
2.000000 > 2.000000
A - B == C, when done correctly!
[ ~ ]

-- 
ERR_NOSIG: sigfile out of commission while removing 'all your base'
           references.


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

Date: Tue, 02 Oct 2001 15:44:11 +0200
From: Eduardo Oliveros <eod_spam@yahoo.es>
To: nobull@mail.com
Subject: Re: Conditional regex substitution
Message-Id: <3BB9C4AB.106A4868@yahoo.es>



nobull@mail.com wrote:

> while (/([^'"]*)((["'])(.*?)\3)?/g) {
>         my ($unquoted_bit, $quoted_bit) = ($1,$4);
>         $unquoted_bit =~ s/=>|[,=; ]//g;
>         no warnings 'uninitialized';
>         $out .= $unquoted_bit . $quoted_bit;
> }

why the "?" at the end of the regex?.

/([^'"]*)((["'])(.*?)\3)?/g
                        ^



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

Date: 02 Oct 2001 17:40:58 +0100
From: nobull@mail.com
Subject: Re: Conditional regex substitution
Message-Id: <u9wv2exaed.fsf@wcl-l.bham.ac.uk>

Eduardo Oliveros <eod_spam@yahoo.es> writes:

> nobull@mail.com wrote:
> 
> > while (/([^'"]*)((["'])(.*?)\3)?/g) {
> >         my ($unquoted_bit, $quoted_bit) = ($1,$4);
> >         $unquoted_bit =~ s/=>|[,=; ]//g;
> >         no warnings 'uninitialized';
> >         $out .= $unquoted_bit . $quoted_bit;
> > }
> 
> why the "?" at the end of the regex?.
> 
> /([^'"]*)((["'])(.*?)\3)?/g
>                         ^

For the same reason as the "no warnings 'uninitialized'".

$_ may not always end with a quoted bit. If this is the case then on
the last iteration the bit inside ()? fails to match and $quoted_bit
will be undefined.

Take out the ? and any stuff following the last quoted bit would be
lost.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Tue, 2 Oct 2001 18:18:59 +0100
From: "S Warhurst" <s.warhurst@rl.ac.uk>
Subject: Efficient code?
Message-Id: <9pcsu3$k10@newton.cc.rl.ac.uk>

Sorry if you guys are getting fed up of helping me.. ignore me if you are ;)

1) If one wants to go through each line of a 100,000 line text file, looking
for one of 50 different strings, is the quickest way to do it (in terms of
processor time) to use 50 IF... ELSIF... commands? (some of these do require
regexp matching.. eg: "I like cornflakes for breakfast" where cornflakes
could be any breakfast cereal).

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

2) If one has an array of email addresses like:

@emails = ('john@here.com', 'tim@there.com', 'bill@anisp.com',
'tim@there.com', 'john@here.com')

and wanted to make them unique I would use the line:

@emails = do {my %h; grep {!$h {$_} ++} @emails}

Is there an easy way to modify this line so that it gives a count of email
addresses aswell, resulting in an array like this:

@emails = (['bill@anisp.com', '1'],
                  ['john@here.com', '2'],
                  ['tim@there.com', '2']);

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

3) If I have an array like the following (there would actually be several
hundred of rows):

@array = (['bath.ac.uk', '46'],
                 ['blackpool.ac.uk', '22'],
                 ['hull.ac.uk', '13'],
                 ['sussex.ac.uk', '36'],
                 ['hull.ac.uk', '31'],
                 ['blackpool.ac.uk', '2']);

and I want to find the unique domains in column 1 and total the values in
column 2 so it looks like this:

@array = (['bath.ac.uk', '46'],
                 ['blackpool.ac.uk', '24'],
                 ['hull.ac.uk', '44'],
                 ['sussex.ac.uk', '36']);

The way I have written it is:

@array = sort { $a->[0] <=> $b->[0] } @array;
$c = 0;
for($r = 0;$r <= $#array;$r++)
{
   if($array[$r][0] ne $array[$r+1][0])
  {
     $domains[$c][0] = $array[$r][0];
     $domains[$c][1] += $array[$r][1];
     $c++;
   }
   else
   {
      $domains[$c][0] = $array[$r][0];
      $domains[$c][1] += $array[$r][1];
    }
}

So, first of all it sorts the array by domain name.
Then, it compares the domain name in the current row with the one in the
next row.
If it is different then it just places the domain name and associated value
in a new array (@domains) and increments $c which keep a count of the
position to enter data in the @domain array.
If it is the same it doesn't increment $c so that when it comes to the next
line it adds the value in column 1 to the existing one. It repeats this
until it's finished.

Is this the most efficient way to do this?

Thanks

---------¦
  Bigus @ work
             ¦----------






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

Date: Tue, 02 Oct 2001 13:10:30 GMT
From: christo <casey1@adelphia.net>
Subject: Re: Embed Sound into cgi?
Message-Id: <50ejrt8n3otrhfnnmdotndc1r5f95emtam@4ax.com>

thanks all for responding, however your responses are over my head,
but im sure my question to resolve is pretty easy. i searched CPAN.org
but did not com up with anything. the URL is
http://www.crystalservice.com/help/bluechat.cgi
Upon logging in the user is in the "chat room" i would like to know
"how" I could get a beep.wav to function to advise me that someone has
entered the room. I would have the chat room running, minimized on my
machine.thanks for any further considerations...

On Mon, 01 Oct 2001 11:27:39 GMT, christo <casey1@adelphia.net> wrote:

>I have a free chat cgi script im running and would like to know if a
>beep sound can be embeded somehow to advise me when someone logs in to
>the chat room. any help would be appreciated.



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

Date: Tue, 02 Oct 2001 16:01:09 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Embed Sound into cgi?
Message-Id: <gmgjrtgdjhu0ccestnmbu199vknon39pv8@4ax.com>

On Tue, 02 Oct 2001 13:10:30 GMT, christo <casey1@adelphia.net> wrote:
>Upon logging in the user is in the "chat room" i would like to know
>"how" I could get a beep.wav to function to advise me that someone has
>entered the room. I would have the chat room running, minimized on my
>machine.thanks for any further considerations...

Please define "running on my machine" - does that mean that a browser is
running on your machine that is logged in to the chat room? Or does that
mean that a web server with the chatroom CGI is running locally on your
machine? What OS are you using on the machine?

If you're on Windows and if you're running a web server with the chat
room locally, a strategically placed 'system( "start whatever.wav" )'
would probably do the trick.

HTH,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


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

Date: Tue, 02 Oct 2001 14:52:14 GMT
From: christo <casey1@adelphia.net>
Subject: Re: Embed Sound into cgi?
Message-Id: <ulkjrtsihpv0tckcmgp8jhsebh7n9t3b0s@4ax.com>

It is running on my machine that is logged in to the chat room. I have
access to the server that is using the cgi script. Im not clear at all
regarding  a strategically placed 'system( "start whatever.wav" )'
 Again the URL is http://www.crystalservice.com/help/bluechat.cgi
What im trying to accomplish  is the same principal that is selling
for $200 at http://www.realtimeaide.com/home.htm
Another words when someone logs in the admistrator is chimed to advise
that somone has logged in. I hope this additional info helps.
thanks for taking your valuable time to consider this.

On Tue, 02 Oct 2001 16:01:09 +0200, Thomas Bätzler
<Thomas@Baetzler.de> wrote:

>On Tue, 02 Oct 2001 13:10:30 GMT, christo <casey1@adelphia.net> wrote:
>>Upon logging in the user is in the "chat room" i would like to know
>>"how" I could get a beep.wav to function to advise me that someone has
>>entered the room. I would have the chat room running, minimized on my
>>machine.thanks for any further considerations...
>
>Please define "running on my machine" - does that mean that a browser is
>running on your machine that is logged in to the chat room? Or does that
>mean that a web server with the chatroom CGI is running locally on your
>machine? What OS are you using on the machine?
>
>If you're on Windows and if you're running a web server with the chat
>room locally, a strategically placed 'system( "start whatever.wav" )'
>would probably do the trick.
>
>HTH,



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

Date: Wed, 3 Oct 2001 01:32:11 +1000
From: "Gregory Toomey" <nobody@nowhere.com>
Subject: Re: GIF encoding
Message-Id: <W3lu7.37795$812.42096@newsfeeds.bigpond.com>


"Philip Newton" <pne-news-20011002@newton.digitalspace.net> wrote in message
news:28iirts28kdmuhoisqcnisf1159teajfoc@4ax.com...
> (You snipped the bit where I quoted you; I think that belongs in this
> discussion.)
>
> On Tue, 2 Oct 2001 09:01:56 +1000, "Gregory Toomey" <nobody@nowhere.com>
> wrote:
>
> > "Philip Newton" <pne-news-20011001@newton.digitalspace.net> wrote in
message
> > news:q91grtsbub7d33nqti1npqjftku6pbkkt5@4ax.com...
> > >
> > > Then you have an old version of the module. Newer versions of the
module
> > > will not write GIF but, instead, PNG (and also JPEG), since that's
what
> > > newer versions of libgd (on which the module is based) write.
> >
> > Correct, but some of us have thousands of users around the world with
olders
> > browsers that support gif but not png.
>
> In that case, you can't point people to "the" GD module, as what people
> will download from CPAN or from boutell.com will not be able to produce
> GIF images.
>
> So the statement "the GD module ... will write in gif format" is false,
> IMO.
>
> Cheers,
> Philip
> --
> Philip Newton <nospam.newton@gmx.li>
> That really is my address; no need to remove anything to reply.
> If you're not part of the solution, you're part of the precipitate.

You need to use an older version of GD (which will be a problem if your
default GD is after 1.19)
http://stein.cshl.org/WWW/software/GD/


gtoomey







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

Date: Tue, 02 Oct 2001 16:04:52 -0000
From: David Wall <darkon@one.net>
Subject: Re: how to get rid of spaces around a string?
Message-Id: <Xns912E7ACD82C4Cdarkononenet@207.126.101.97>

"Wyzelli" <wyzelli@yahoo.com> wrote on 01 Oct 2001:
> 
> s/^\s*(.*?)\s*$/$1/;
> 
> Which I prefer to the two seperate entries in the FAQ (despite getting
> in trouble with certain peoples because of it), because this is a FAQ.

I suspect the FAQ recommends using two statements instead of one because 
the two statements use about a third of the processing time that the one-
statement version does.


use Benchmark;
timethese( 1000000, {
    one => '$_ = "    stuff    "; s/^\s*(.*?)\s*$/$1/',
    two => '$_ = "    stuff    "; s/^\s*//; s/\s*$//;'
});

On my system (admittedly rather old and slow), I get:

Benchmark: timing 1000000 iterations of one, two...
       one: 33 wallclock secs (31.85 usr +  0.05 sys = 31.90 CPU) @ 
31351.89/s (n=1000000)
       two: 10 wallclock secs (11.05 usr +  0.01 sys = 11.06 CPU) @ 
90448.63/s (n=1000000)


-- 
David Wall
darkon@one.net


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

Date: Tue, 02 Oct 2001 18:45:01 +0200
From: Jean-Philippe Fauvelle <JPFauvelle@Colt-Telecom.fr>
Subject: Re: how to send mail without sendmail
Message-Id: <8tqjrt8urdukj2tlqqp9cdsg93jte8ek2s@4ax.com>

Le Sun, 30 Sep 2001 18:32:50 -0400, Zimmen Gnauh <yah00204052@yahoo.com> +AOk-crit:

>   My unix system does not have sendmail (somehow removed by admin). Is
>there any way to send mail without it?

Use Net::SMTP (libnet package).

Regards.

Jean-Philippe Fauvelle



###################################
# Example one : simply send an email
###################################

use Net::SMTP;
$SMTP_HOST = 'name.domain.com'; # where your SMTP server resides

$smtp = Net::SMTP->new($SMTP_HOST,Timeout=>30) or die 'server unreachable';
$smtp->mail('recipient@domain.com');
$smtp->recipient('recipient@domain.com');
$smtp->data;
$smtp->datasend(<<END_OF_MESSAGE);
From: <visible_sender+AFw-@domain.com>
To: <visible_recipient+AFw-@domain.com>
Subject: test

Helo,
wolrd
END_OF_MESSAGE

$smtp->dataend;
$smtp->quit;

#######################################################
# Example two: send an email with attachment and MX resolution....
# This piece of code use your DNS server to determine where
# resides the recipient's mail server.
# Then, it delivers the email directly to the mail server of the
# recipient's domain.
#######################################################

use Net::SMTP;
use MIME::Lite;

$mail_from  = 'sender@domain.com';
$rcpt_to    = 'recipient@domain.com';
$from       = '<sender@domain.com> (Visible sender)';
$to         = 'recipient@domain.com (Visible recipient)';
$subject    = 'Test with an attcment';
$msg = q{
This is a message
with an attachment
};

$attch = q{
This this the content of the attachment.
You can load binary data if you want..
};

# Create the message (header +- body)
$liteObj = MIME::Lite->new(
    From       => $from,
    To         => $to,
    Subject    => $subject,
    Encoding   => 'quoted-printable',
    Type       => 'text/plain',
    Data       => $msg
);

# Attach a file
$liteObj->attach(
    Type            => 'application/octet-stream',
    Encoding        => 'base64',
    Filename        => 'visible_file_name',
    Data            => $attch
);

# Try to deliver (simple version)
MX:foreach $mxHost ( searchMX($rcpt_to) ) {
     eval { 
	# ignore 'ESMTP not supported' warnings
         local $SIG{__WARN__} = sub {  };  
         
         $smtpObj = Net::SMTP->new( $mxHost, Timeout => 10) or next MX;
         $smtpObj->mail($mail_from)               or next MX;
         $smtpObj->to($rcpt_to)                   or next MX;
         $smtpObj->data                           or next MX;
         $smtpObj->datasend($liteObj->as_string)  or next MX;
         $smtpObj->dataend                        or next MX;
         $smtpObj->quit                           or next MX;
     };
     print "Mail delivered to $mxHost+AFw-n";
     last;
}



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

Date: Tue, 02 Oct 2001 18:57:19 +0200
From: Jean-Philippe Fauvelle <JPFauvelle@Colt-Telecom.fr>
Subject: Re: how to send mail without sendmail
Message-Id: <c0sjrtgo3sv04c5tlkaecshdqh9sppvuma@4ax.com>

Le Tue, 02 Oct 2001 18:45:01 +-0200, Jean-Philippe Fauvelle
<JPFauvelle@Colt-Telecom.fr> +AOk-crit:

>Le Sun, 30 Sep 2001 18:32:50 -0400, Zimmen Gnauh <yah00204052@yahoo.com> +AOk-crit:
>
>>   My unix system does not have sendmail (somehow removed by admin). Is
>>there any way to send mail without it?
>
>Use Net::SMTP (libnet package).
>
>Regards.
>
>Jean-Philippe Fauvelle
>

And here is the serchMX function missing in my previous message.



use Net::DNS::Resolver;

# test it !
print searchMX('www.fth.net'), "+AFw-n";    #  'zd.mx.aol.com', 'yb.mx.aol.com'
print searchMX('netscape.com'), "+AFw-n";   #  'xwing.netscape.com'...
print searchMX('bob@aol.com'), "+AFw-n"; #  'xwing.netscape.com'...

#==============================================================================
# searchMX($hostname||$email) -> ($MXhostname,$MXhostname,...) 
# result is sorted by descending priority
#==============================================================================
sub searchMX {
        my $rcptAddr = shift;
        my($resolver,$query,$record,@mx,@a,$addr);

        $addr = $rcptAddr;
        $addr =+AH4- s/^.*+AFw-@//;  # email -> domain
        $resolver = Net::DNS::Resolver->new;

        while ($addr=+AH4-/+AFw-./) {
                
                # search for MX records
                if ( $query = $resolver->query($addr,'MX','IN') ){ 

                        @mx = map {$_->exchange} 
                              sort { $a->preference <=> $b->preference } 
                              grep { $_->type eq 'MX' } $query->answer;

                        return @mx if @mx;

                } # else, search for the 1st 'A' record
                elsif ( $query = $resolver->query($addr,'A','IN') ){ 
                        @a = map {$_->address}  grep { $_->type eq 'A' }
$query->answer;
                        return $a[0] if @a;
                }
                
                # compact the name if the search failed
                $addr =+AH4- s/^[^+AFw-.]+ACsAXA-.//; 
        }

        return; # no MX server found !




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

Date: Tue, 2 Oct 2001 12:44:26 -0400
From: Jag Man <a0197620@MailAndNews.com>
Subject: identifying bogus email address formats
Message-Id: <3BE9586B@MailAndNews.com>

Need some help filtering bogus email formats.

bogus email format examples:
test@test@test.com
test@@@@@@@@@@test.com
test@test..com
 ...

The following sub can't pickup above conditions:
###############################################
sub checkEmailAddrSyntex {
        my $emailAddr = $_[0];
        my $EmailFlag = "Valid";

        if ($emailAddr !~ /\w+@.+\.(\w{2,4})$/) {
                $EmailFlag = "NotValid";
        }

        if ($emailAddr =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\@\@)/) {
                $EmailFlag = "NotValid";
        }

        if ($emailAddr =~ 
/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) {
                $EmailFlag = "NotValid";
        }

        return($EmailFlag);
}

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

TIA!

------------------------------------------------------------
 Get your FREE web-based e-mail and newsgroup access at:
                http://MailAndNews.com

 Create a new mailbox, or access your existing IMAP4 or
 POP3 mailbox from anywhere with just a web browser.
------------------------------------------------------------



-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: 02 Oct 2001 10:10:02 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: identifying bogus email address formats
Message-Id: <m17kue9ded.fsf@halfdome.holdit.com>

>>>>> "Jag" == Jag Man <a0197620@MailAndNews.com> writes:

Jag> Need some help filtering bogus email formats.
Jag> bogus email format examples:
Jag> test@test@test.com

That's not bogus.

Jag> test@@@@@@@@@@test.com

That's not bogus.

Jag> test@test..com

That is.

See Email::Valid in the CPAN (and something else with RFC822 in the name).

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 2 Oct 2001 07:36:29 -0700
From: kevinket@yahoo.com (Kevin Ketchum)
Subject: IE user jamming the Stop button while Perl/IIS processing html post request
Message-Id: <d32be58c.0110020636.312ed50a@posting.google.com>

I've set up a database search form that allows the user to search a
database for data in specific fields.

This all bolts to a .pl script that connects to an MSAccess database
via Win32::ODBC.  This database has <6500 records.

The problem:  If the user gets impatient while the sql query is
happening or when the records are being returned to their browser,
they may hit the browser STOP button.  This results in a rouge
PERL.EXE (I've tried PERLIS.DLL as well) that sucks 50%-80% of the
CPU.  As more and more requests are sent/cancelled, more instances of
PERL.EXE are left, soon taking 100% of the CPU.

Is my basic approach for accessing the MSAccess database acceptable?
- If no, what direction should I take?

- If yes, how does one handle this rouge PERL process if a user hits
the IE Stop button?


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

Date: Tue, 02 Oct 2001 16:59:38 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: Installing a Module in my own directory??
Message-Id: <3BB9E46A.BD35A033@oracle.com>

This is a multi-part message in MIME format.
--------------388A76D8DD5C97D8A2340A87
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

> now how do i call it?
>
> use SimpleLinkChecker;
>
> or do i specify the path to it ? No its not in then root directory - i
> put it i my own directory.

To tell perl where to find modules if they aren't in the default locations
use
use lib "path/to/directory/where/the/module/files/are";
# and make sure it appears before the statement using the module itself.
use SimpleLinkChecker;

Graham Wood

--------------388A76D8DD5C97D8A2340A87
Content-Type: text/x-vcard; charset=UTF-8;
 name="Graham.T.Wood.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Graham Wood
Content-Disposition: attachment;
 filename="Graham.T.Wood.vcf"

begin:vcard 
n:;Graham
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:Graham.T.Wood@oracle.com
fn:Graham Wood
end:vcard

--------------388A76D8DD5C97D8A2340A87--



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

Date: 2 Oct 2001 06:22:03 -0700
From: patrik.nyman@orient.su.se (Patrik Nyman)
Subject: MacPerl newbie question
Message-Id: <691f56e3.0110020522.3fc33bbf@posting.google.com>

I want to run the following script with MacPerl. I've tried saving it
as a droplet, but it doesn't do anything with the input file dropped
on it. What do I do wrong? Sorry for making this message so long, but
I thought it would be just as well to append the whole script.

#!perl
#-*-Perl-*-

#--------------------------------------------------------------#
$description =
"Syntax: mbh2dn [options] [file]

Mbh2dn reads Mahýbhýrata text in John Smith's CSX revision of
Prof. Tokunaga's format and outputs it in Frans Velthuis's DN
format, so that high quality printed output in Devanagari can
be obtained via TeX.

-h option prints this help.
-p <string> assigns \"string\", which should be in CSX encoding,
            as the name of the parvan (printed in the header).
            (By default, the filename is used, stripped of
            leading paths and numerals, trailing extensions,
            and the underscore character.)
";
#--------------------------------------------------------------#

require 'getopts.pl';
do Getopts('p:h');
if ($opt_h) {
    print $description;
    exit 1;
}

$chnum = $curchap = $newchap = $uvaaca = $prevuv = $prose = $curpr =
$lnum = $prnum = 0;
$curline = "0";
if ($opt_p) {
    $parvan = $opt_p;
}
else {
    $parvan = $ARGV[0];
    $parvan =~ s/.*\/([^\/]*)/$1/;
    $parvan =~ s/\..*$//;
    $parvan =~ s/^[0-9]*//;
    $parvan =~ s/([A-zÄ-*]|^)_([A-zÄ-*])/$1$2/g;
    $parvan =~ s/_/ /g;
    $parvan =~ s/-/--/g;
    $parvan =~ s/parvan$/parva/;
}

%prconv = ("A", "1",
	   "B", "2",
	   "C", "3",
	   "D", "4",
	   "E", "5",
	   "F", "6",
	   "G", "7",
	   "H", "8",
	   "I", "9",
	   "J", "10",
	   "K", "11",
	   "L", "12",
	   "M", "13",
	   "N", "14",
	   "O", "15",
	   "P", "16",
	   "Q", "17",
	   "R", "18",
	   "S", "19",
	   "T", "20",
	   "U", "21",
	   "V", "22",
	   "W", "23",
	   "X", "24",
	   "Y", "25",
	   "Z", "26");

open(STDOUT, "|csx2tex |tex2dn -s");

print <<EOS;
\\input genmacs
\\input dnmacs
\\dnnum
\\def \\\\{\\par}%
\\def \\!{\\par\\nobreak}%
\\def \\,{~}%
\\def \\prnum#1{\\raise1ex\\hbox{\\dntiny ..\\,#1..}}%
\\newdimen \\bigleftskip
\\bigleftskip = \\hsize \\divide \\bigleftskip by 4%
\\leftskip = \\bigleftskip
\\headline = {\\dn \\smalldn \\mbh \\hfil \\parvan}%
%
{\\dn \\gdef \\mbh {mahaabhaarate}}
{\\dn \\gdef \\parvan {$parvan}}
%
%
EOS

while (<>) {
    if (/^[%\\]/) {
	print;
	next;
    }
    chop;
    s/^([0-9]*[A-Z]*\s*)//;
    $curprnum = $prnum;
    $numstring = $1;
    $chnum = substr($numstring, 2, 3);
    $chnum =~ s/^0*//g;
    $lnum = substr($numstring, 5, 3);
    $lnum =~ s/^0*//g;
    $prnum = substr($numstring, 8, 1);
    if ($numstring =~ /  $/) {
	$uvaaca = 1;
    }
    else {
	$uvaaca = 0;
    }
    if ($prnum =~ /[A-Z]/) {
	$prose = 1;
	$prnum = $prconv{$prnum};
    }
    else {
	$prose = 0;
    }
    if ($chnum ne $curchap) {				# New chapter
	print "\\,||\\,$curline||\\\\}\n" unless $curline eq "0";
	print "\\vskip 0.5 in plus 5 pt minus 5 pt\n";
	print "\\goodbreak\n";
	print "\\centerline {\\dn \\bigdn $chnum}\n";
	print "\\vskip 0.3 in plus 2 pt minus 2 pt\n";
	$curchap = $chnum;
	$newchap = 1;
	$curline = "0";
	$prevuv = 0;
    }
    else {
	$newchap = 0;
    }
    if ($uvaaca) {					# X uvýca
	print "\\,||\\,$curline||\\\\}\n" unless $curline eq "0";
        print "\\medbreak\n" unless $newchap;
	print "{\\dn \\qquad \\qquad \\qquad \\qquad $_}\n";
	print "\\medskip\n";
	$prevuv = 1;
    }
    else {						# MBh text
	if ($curpr && $prose) {				# Continuing prose
	    print "%\n\\prnum{$curprnum}}\\,\\,%\n";
	    if ($curline ne $lnum) {
		print "{\\dn ||\\,$curline||\\,}\n" unless ($curline eq "0" ||
$prevuv);
		$curline = $lnum;
		$prevuv = 0;
	    }
	}
	elsif ($curpr && !$prose) {			# End of prose
	    if ($curline ne $lnum) {
		print "%\n\\prnum{$curprnum}}\\,\\,%\n";
		print "{\\dn ||\\,$curline||\\\\}\n" unless $curline eq "0";
		$curline = $lnum;
	    }
	    else {
		print "%\n\\prnum{$curprnum}\\\\}\n";
	    }
	    print "\\leftskip = \\bigleftskip \\rightskip = 0 pt\n";
	    $curpr = 0;
	    $prevuv = 0;
	}
	elsif ($curline eq $lnum) {			# End of odd pýda
	    print "\\,|\\!}\n";
	    $prevuv = 0;
	}
	else {
	    print "\\,||\\,$curline||\\\\}\n" unless ($curline eq "0" ||
$prevuv);
	    $curline = $lnum;
	    $prevuv = 0;
	}
	if ($prose && !$curpr) {			# Start of prose
	    print "\\leftskip = 0.5 in \\rightskip = 0.5 in \\noindent\n";
	    $curpr = 1;
	    $prevuv = 0;
	}
	print "{\\dn ";
	s/; /\\!}\n{\\dn \\qquad /g;			# Tri*Òubh
	s/;/-\\!}\n{\\dn \\qquad /g;
	print $_;
	$newchap = 0;
    }
}
print "\\,||\\,$curline||\\\\}\n" unless ($curline eq "0" || $prevuv);
print "%\n%\n\\bye\n";


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

Date: Tue, 02 Oct 2001 13:49:57 -0000
From: David Wall <darkon@one.net>
Subject: Re: Passing arguments to subs
Message-Id: <Xns912E63EDD1525darkononenet@207.126.101.97>

"David K. Wall" <darkon@one.net> wrote on 30 Sep 2001:
> Isn't a standard way to do this is to use a dispatch table, using a
> hash where the keys are what you expect the browser to send, and the
> values are subroutine references?  (Uri Guttman recommended this to
> someone a few days ago, IIRC)

I gather from the echoing silence that my post was either (a) a post not 
needing a reply, (b) a silly question (a subset of (a), I suppose), or (c) 
Randal is trapped under something heavy and can't respond.  I'm betting on 
(a) or (b).  :-)

-- 
David Wall
darkon@one.net


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

Date: Tue, 02 Oct 2001 16:44:22 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Passing arguments to subs
Message-Id: <mbudash-6DE89F.09442502102001@news.sonic.net>

In article <Xns912E63EDD1525darkononenet@207.126.101.97>, David Wall 
<darkon@one.net> wrote:

> "David K. Wall" <darkon@one.net> wrote on 30 Sep 2001:
> > Isn't a standard way to do this is to use a dispatch table, using a
> > hash where the keys are what you expect the browser to send, and the
> > values are subroutine references?  (Uri Guttman recommended this to
> > someone a few days ago, IIRC)
> 
> I gather from the echoing silence that my post was either (a) a post not 
> needing a reply, (b) a silly question (a subset of (a), I suppose), or 
> (c) Randal is trapped under something heavy and can't respond.  I'm betting 
> on (a) or (b).  :-)

my only comment would be on your use of the adjective 'standard'... 
although uri's recommended way is certainly elegant, there really are no 
'standard' ways to do anything in perl - and that's why we all love perl 
so much! TMTOWTDI
 
my .02,
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 1856
***************************************


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