[6515] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 140 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 18 18:07:59 1997

Date: Tue, 18 Mar 97 15: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           Tue, 18 Mar 1997     Volume: 8 Number: 140

Today's topics:
     /RE/ for Dummies - Match all caps (Robert Schuldenfrei)
     Re: Assignment of string not working (Tad McClellan)
     Re: BUG? Improper variable interpolation in patterns? <dbenhur@egames.com>
     Cutting off the first letter. <glass@asu.edu>
     Debugging warnings and "die". (Topher Eliot)
     Re: Debugging warnings and "die". (Ilya Zakharevich)
     Directory access Denying (Jeremy Coulter)
     Re: Elegant way to strip spaces off the ^ and $ of a va <merlyn@stonehenge.com>
     Re: Elegant way to strip spaces off the ^ and $ of a va (The Man on the Scene)
     File Manager in CGI/Perl <Laurent.Julliard@grenoble.rxrc.xerox.com>
     flock() - Just the basics (Robert Schuldenfrei)
     Help needed with PERL script!! (Neil Johnson)
     Help on Shopping Cart <sturner1@gte.net>
     Re: How to read a Fixed Format File? <dbenhur@egames.com>
     Is it Possible? (Greg Skafte)
     Is NDBM_File a _complete_ module? <jstrick@mindspring.com>
     Lost backslash <buehner@pfaffenhofen.netsurf.de>
     Re: Q: Good Perl Book <buehner@pfaffenhofen.netsurf.de>
     Re: Reg. expression question <usenet-tag@qz.little-neck.ny.us>
     Re: Split <dbenhur@egames.com>
     Re: What's wrong with "an email" (Bruce M. Binder)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 18 Mar 1997 22:04:18 GMT
From: sailboat@tiac.net (Robert Schuldenfrei)
Subject: /RE/ for Dummies - Match all caps
Message-Id: <5gn3es$net@news-central.tiac.net>

I have been having a problem trying to match lines in which everything is
capitalized.  We have some manuals that use all caps and I would like to pretty
them up with just initial caps.

Thus I would like the following line:

   THIS IS ALL CAPS

To be converted into:

   This Is All Caps

My first probe at this was:

if(/[A-Z]+/) {
	tr/[A-Z]/[a-z]/;
	}

But that translated every line of text, not just the lines of all caps.  I am
obviously missing something basic in RE, but I do not know what it is.  Please
enlighten me.  TIA  Bob

 .
Robert Schuldenfrei
S. I. Inc.
32 Ridley Road
Dedham, MA  02026
Voice: (617) 329-4828
FAX:   (617) 329-1696
E-Mail: bob@s-i-inc.com
WWW:    http://www.tiac.net/users/tangaroa/index.html



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

Date: Tue, 18 Mar 1997 12:29:17 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Assignment of string not working
Message-Id: <ttmmg5.hf2.ln@localhost>

Philip Ives (st94zm5g@dunx1.ocs.drexel.edu) wrote:
: Followup-To: 
: Distribution: 
: Organization: Drexel University, Philadelphia
: Keywords: 
: Cc: 


What are the _headers_ doing in the _body_ ??

Looks like your newsreader is misconfigured or something...


: In my script I am assigning a string variable to the $to variable to sendmail.

Huh?


: It does not seem to be working and I cannot figure out why.  The variable is 
: coming from a form that I am splitting the name value pairs frmo
: the assignment is:the assignment is:the assignment is:the assignment is:the assignment is:the assignment is:


Huh?:Huh?:Huh?:Huh?:Huh?:Huh?


: $to= "$contents('outAddress')";

$to= "$contents{'outAddress'}";
               ^            ^


: please reply to st94zm5g@post.drexel.edu

Nope.


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Tue, 18 Mar 1997 11:30:30 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: Marc Rouleau <mer@world.evansville.net>
Subject: Re: BUG? Improper variable interpolation in patterns?
Message-Id: <332EED56.7F1B@egames.com>

[mail&post]
Marc Rouleau wrote:
> $_ = '$x'; $a = '$x'; $b = '\$x';
> print "\$a matched\n" if /$a/;
> print "\$b matched\n" if /$b/;
> 
> My output from this fragment is
>   $b matched

'$' is a regex meta-character that matches at end-of-string
or end-of-line depending on the /s or /m suffix or the value
of $*.  Your $b pattern uses \ to escape the $ removing
it's meta-character status in the pattern match (it will
match a literal $ as you were hoping).  Use the quotemeta
function to remove unexpected meta-character interpretations
from interpolated variables in regex patterns. eg:

   $a = quotemeta $a;
   print "\$a matched\n" if /$a/;

or the equivalent:
   print "\$a matched\n" if /\Q$a\E/;

HTH
--
Devin Ben-Hur      <dbenhur@egames.com>
eGames.com, Inc.   http://www.egames.com/
eMarketing, Inc.   http://www.emarket.com/
"Sometimes you just have to step in it and see if it stinks"  O-
    -- Sonia Orin Lyris



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

Date: Tue, 18 Mar 1997 14:24:37 -0700
From: Gene Glass <glass@asu.edu>
Subject: Cutting off the first letter.
Message-Id: <332F0814.693E@asu.edu>

I am stuck trying to find a way of cutting off the initial letter in
a word that has been associated with a variable and then use that letter
as a variable itself. Have tried chop (wrong end), split, slice, reverse
 ...I don't know that much Perl to start with and I'm out of leads.
   Here's the problem:
   I read in a person's last name and call it $name. Now I want to
isolate the first letter of that name and call it $letter. How is this
done?
  Thanks for any help.     Gene Glass   glass@asu.edu


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

Date: 18 Mar 1997 19:46:05 GMT
From: eliot@kern1.dg.com (Topher Eliot)
Subject: Debugging warnings and "die".
Message-Id: <ELIOT.97Mar18144605@kern1.dg.com>

Please excuse if this is a repeat; I've been having trouble posting.

Is there a way to arrange to run perl in debugging mode with warnings
enabled (i.e. perl -dw) so that when a warning is generated, I hit a
breakpoint, and can examine the program's state?

Similarly, can I arrange to stop in the debugger when "die" is executed?

Topher Eliot                           Data General Unix Core Development
(919) 248-6371                                        eliot at dg-rtp.dg.com
Obviously, I speak for myself, not for DG.
Visit misc.consumers.house archive at http://www.geocities.com/Heartland/7400
"I like to get the chicks messy."  
	-- Peter, age 4, on why he likes the barnyard-scene cereal bowl.


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

Date: 18 Mar 1997 20:18:45 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Debugging warnings and "die".
Message-Id: <5gmtb5$ofh$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Topher Eliot
<eliot@kern1.dg.com>],
who wrote in article <ELIOT.97Mar18144605@kern1.dg.com>:
> Please excuse if this is a repeat; I've been having trouble posting.
> 
> Is there a way to arrange to run perl in debugging mode with warnings
> enabled (i.e. perl -dw) so that when a warning is generated, I hit a
> breakpoint, and can examine the program's state?
> 
> Similarly, can I arrange to stop in the debugger when "die" is executed?

I hope you know about $SIG{__WARN__} and $SIG{__DIE__}? I hope you
know how to stop debugger from your code ($DB::single)?

Ilya


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

Date: Tue, 18 Mar 1997 19:36:57 GMT
From: vss@xtra.co.nz (Jeremy Coulter)
Subject: Directory access Denying
Message-Id: <332fed36.53907879@202.37.101.7>

Hi There.

A friend asked me to write a perl script that deals with Passwords to
stop people getting access to certain pages on his server.

As I explained to him, once they are in, they only have to bookmark
the page, and they can by-pass the password log in.

So I suggested that allowing only certain people access to a directory
where the pages are stored.

I have a perl book that told me that I can use "AuthDBMUserFile" to
point to a file that houses valid users names, and therefore, only
thoses people can get access to that directory.
The only thing is, I don't know how to use this procedure, and my book
leaves me a bit in the dark.

Does anybody have an example of what I want to do ?


Cheers Jeremy Coulter


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

Date: 18 Mar 1997 12:49:06 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: aeb@saltfarm.bt.co.uk
Subject: Re: Elegant way to strip spaces off the ^ and $ of a variable containing a sentence.
Message-Id: <8cenddt1zh.fsf@gadget.cscaper.com>

>>>>> "Tony" == Tony Bass <aeb@calf.saltfarm.bt.co.uk> writes:

Tony> From article <8csp1xydui.fsf@gadget.cscaper.com>, by Randal Schwartz <merlyn@stonehenge.com>:
>>>>>>> "Chris" == Chris Russo <crusso@alink.net> writes:

Tony> The foreach rendering may be awkward if the input list is generated by
Tony> complex calculations.  An actual example

Tony>     grep { vec($result, $outp++, 32) = $_ if (not $seen[$_]++); }
Tony>      map { $_ ? ($_ + $r) : (@edge); } @dedge;

Tony> would be tolerable in foreach form but indicates what might happen if
Tony> the mapping became more complicated (eg a composition of two maps).
Tony> (And also, conceptually this particular example *is* list output - only
Tony> the representation has changed!)

So?  I often write:

	foreach (
		map { ... } @dedge
	) {
		vec($result, $outp++, 32) = ...;
	}

So that map *can* get arbitrarily complicated, and you *still* don't
need grep to walk through the list.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 531 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: 18 Mar 1997 16:20:40 GMT
From: shaug@callamer.com (The Man on the Scene)
Subject: Re: Elegant way to strip spaces off the ^ and $ of a variable containing a sentence.
Message-Id: <5gmfco$lat$1@zinger.callamer.com>

In article <5qn2s3cx5n.fsf@elara.frii.com>,
	Nathan Torkington <gnat@elara.frii.com> writes:
> Tom Christiansen <tchrist@mox.perl.com> writes:
>> :And why set $_ to the element of the array in stead of a copy if we
>> :aren't supposed to use the side effects?
>> 
>> Why?  I can tell you that: Because it was an accident the first time, and
>> people started using it, so Larry doc'ed it.  As far as I'm concerned,
>> it's kinda dodgy and mystifying.
> 
> ...
> 
> Of course, *aesthetics* are a different matter.  If, as I suspect, Tom
> doesn't like because it's just plain ugly and an oozing LISPish wound
> on the otherwise virgin and unblemished cheeks of the blushing and
> fair maiden we call Perl, then we're verging into taste wars.  I've
> been to Tom's place.  You don't want to get into taste wars with Tom
>:-)
> 
> Nat
> 

	Wow, Nat!  You can make bea-u-ti-ful poetry.  Shouldn't that second
	sentence go on www.perl.org's poetry page?  :)  
	
	[ Disclaimer: I have no idea what's under that link right now, due 
	to some weird problem on the Internet starting at tci4500-e1.msu.edu ]

-- 
O'Shaughnessy Evans
UNIX/Internet Systems Administrator, GST-Call America; SLO, CA
mailto: shaug@callamer.com; http://gromit.callamer.com


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

Date: Tue, 18 Mar 1997 12:38:35 +0100
From: Laurent Julliard <Laurent.Julliard@grenoble.rxrc.xerox.com>
Subject: File Manager in CGI/Perl
Message-Id: <332E7EBB.74800BB8@grenoble.rxrc.xerox.com>

I'm about to write a set of CGI scripts to have the equivalent
of a File Manager available from my Web browser. I'd like to
have something as close as possible  to the Windows 3.1 File Manager.

Does anybody know of existing scripts/modules in Perl that would
do that ?

Thanks
-- 
---------------------------------------------------------------------
Laurent JULLIARD             Laurent.Julliard@grenoble.rxrc.xerox.com
Rank Xerox Research Centre  
http://www.rxrc.xerox.com/ats/personal/julliard/
6, chemin de Maupertuis      Phone   : (+33) (0)4 76 61 50 48
38240 MEYLAN / FRANCE        Fax     : (+33) (0)4 76 61 51 99
---------------------------------------------------------------------


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

Date: Tue, 18 Mar 1997 22:11:09 GMT
From: sailboat@tiac.net (Robert Schuldenfrei)
Subject: flock() - Just the basics
Message-Id: <5gn3ro$net@news-central.tiac.net>

I am trying to learn how to use flock().  My old SCO box seems to have it, but I
am probably using it wrong.  Is there some documentation for flock() on version
3.2.2 of SCO UNIX?  One program is opening the file for writing and then locking
the file like this:

open(OUTFILE, "myfile");
flock(OUTFILE, 02);

The other program is trying to read that file.  I do not know the test in the
reading program to see if the file is locked.  If so, the second program should
sleep and then try again.  I am not sure of the codes for flock().  I think 02
is to lock the file before writing, and 03 is to remove the locks before
closing.  I would like to know the answer, but even more important some good
source reference would be a great help.  Thanks for you help.

 .
Robert Schuldenfrei
S. I. Inc.
32 Ridley Road
Dedham, MA  02026
Voice: (617) 329-4828
FAX:   (617) 329-1696
E-Mail: bob@s-i-inc.com
WWW:    http://www.tiac.net/users/tangaroa/index.html



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

Date: Tue, 18 Mar 1997 20:50:25 GMT
From: njohnson@enterprise.net (Neil Johnson)
Subject: Help needed with PERL script!!
Message-Id: <332edf79.4812106@news.enterprise.net>

I hope someone can help me here!

I have written the perl script below which creates an index html page
of all the files on a sever. The problem is I want to add a few more
features to make it more useful but just can't seem to get them to
work!

At the moment it gives file name, directory, size of file and date of
file in days. What I am trying to add is a function that would get the
file dates as well. I have found no switch for this like you can use
to get the other information so hopefully someone out there know's how
this can be done!

I also want to get it to scan for command line paths. At the moment it
just displays the whole file system but I would like it also to start
scanning from  a certain directory as well. So if someone ran the
script by: indexer.pl?d:\wwwroot\ftp\

It would start scanning from there istead of the deafult. Can this be
done?

One last query I have is that I have made it calculate the total size
of the directires in MB but I want to format this number in a way so
it adds a comma every three digits so if the total was: 999999999 it
would be formatted to 999,999,999. 

Can that be implemented??

Script is below:

#!/usr/bin/perl -w 

$dir = '..';

# Create HTML file & content header

print "<Content-type: text/html\n\n>";
print "
<HTML>
<HEAD><TITLE>File Index</TITLE></HEAD>
<BODY BGCOLOR=#FFFFFF>
<FONT FACE=Arial>
<P>
<H2>Indexer v2.0</H2>
</P>
<TABLE>
<TR>
<TD><B>Directory </B></TD>
<TD><B>File Name</B></TD>
<TD><B>Size(Bytes) </B></TD>
<TD><B> Age(days)</B></TD>
</TR>
<TD><HR></TD><TD><HR></TD><TD><HR></TD><TD><HR></TD>
";

$TotalSize = 0;
$DirSize = 0;
&traverse($dir);                           

sub traverse {
    local($DirSize) = 0;
    local($dir) = shift;
    local($path);
    unless (opendir(DIR, $dir)) {
        warn "Can't open $dir\n";  
	closedir(DIR);
	return;
    }
    foreach (readdir(DIR)) {
	next if $_ eq '.' || $_ eq '..';
	$path = "$dir/$_";
	if (-d $path) {                       
	    &traverse($path);
        } elsif (-f _) {                             
        $size = -s _;                             
        $age = int (-M _);                         
        $DirSize = $DirSize + eval(-s _); 
	print "
	<TR>
	<TD>$dir</TD>
	<TD>$_</TD>
	<TD ALIGN=RIGHT>$size</TD>
	<TD ALIGN=RIGHT>$age</TD>
        </TR>";
	}
    }
    print "<TR><TD><B>$dir</B></TD><TD><B>Total Dir</B></TD><TD
ALIGN=RIGHT><B>$DirSize</B></TD></TR>";
    $TotalSize = $TotalSize + $DirSize;	
	closedir(DIR);
}
	$TotalSizeMb = ($TotalSize / 1024) / 1024;
	print "
</TABLE>
<H2>Total in directory tree $dir = $TotalSizeMb Mb</H2><P>
<HR>
</FONT>
</BODY>
</HTML>
";

Hopefully someone can shed light on my problems and hopefully solve
them!!

Neil


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

Date: 18 Mar 1997 20:52:42 GMT
From: "Webwalkers" <sturner1@gte.net>
Subject: Help on Shopping Cart
Message-Id: <01bc33df$195d4dc0$5f9773cf@ia.airmail.net>

Hello,

I am working on a shopping cart script that needs some modification.  Since
I don't know much about scripting, I don't know where to begin.  If someone
out there would like to help, please e-mail me.  I would greatly appreciate
any help!

Thanks,

Tammy
sturner1@gte.net


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

Date: Tue, 18 Mar 1997 11:45:46 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: Baruch Promislow <baruch@macom.co.il>
Subject: Re: How to read a Fixed Format File?
Message-Id: <332EF0EA.279D@egames.com>

[mail&post]
Baruch Promislow wrote:
> Is there a way to define a FORMAT for inputing from fixed formatted files,
> similar to the output formats?

look at unpack()

man perlfunc or Camel p.236,195-197

--
Devin Ben-Hur      <dbenhur@egames.com>
eGames.com, Inc.   http://www.egames.com/
eMarketing, Inc.   http://www.emarket.com/
"Sometimes you just have to step in it and see if it stinks"  O-
    -- Sonia Orin Lyris



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

Date: 18 Mar 1997 20:00:12 GMT
From: skafte@news.worldgate.com (Greg Skafte)
Subject: Is it Possible?
Message-Id: <5gms8d$sh5@scanner.worldgate.com>

Is it possible  to untaint an unlink command in suid/sgid enviroment

most of my endevours get me something like:

	Insecure dependency in unlink while running setgid 
	at /usr/local/sbin/.numeric-page line 88.




--
Email: skafte@worldgate.com	  Voice: +403 413 1910	  Fax: +403 421 4929
   #575 Sun Life Place * 10123 99 Street * Edmonton, AB * Canada * T5J 3H1 
--                                                                        --
PGP 2.6.2 Key fingerprint =  42 9C 2C A8 4D 2B C9 C4  7D B6 00 B0 50 47 20 97 
http://gras-varg.worldgate.com/~skafte/             http://www.worldgate.com/
--								          --
When things can't get any worse, they simplify themselves by getting a whole
lot worse then complicated. A complete and utter disaster is the simplest
thing in the world; it's preventing one that's complex.       (Janet Morris)


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

Date: Tue, 18 Mar 1997 15:22:03 -0500
From: John Strickler <jstrick@mindspring.com>
Subject: Is NDBM_File a _complete_ module?
Message-Id: <332EF96B.6891AB78@mindspring.com>

I am trying to use NDBM_File under Solaris 2.5 with perl 5.003; for some
reason, when Perl 
was built, it did not install the NDMB_File module, since there was no
lib for ndbm; however,
Solaris supports ndbm, apparently, because I have man pages, and built a
simple C program which uses dbm_open() and friends, and that worked
fine. 

So OK, I'm a programmer and a Perl guy; I explode the Perl src tree and
go to $PERL/ext/NDBM_File,
and do the usual things to build a module. I 'make install' and
everything looks good, but when
I put the following code in my program, it seems that NDBM_File does not
have a method for EXISTS.
(from Tie::Hash). I thought that NDBM_File should have a class that
inherits Tie::Hash::EXISTS
and does something useful.

It built the empty DB files OK, AFAIK. (They're there.) Note: sadly, I
can't show you the exact
error, because I destroyed my current Perl installation as part of
rebuilding Perl to make sure
I wasn't missing things, so I can't run perl right this minute. :-(

# code sample begins
use NDBM_File;  

tie(%ip_addr,NDBM_File,'ip_addr',0x100|0x02, 0660) or die("Hmmm...$!");

while (<>) {
[ unimportant (to NDBM_File!) code which ultimately sets $name to a host
name ]
    print STDERR "DUPE! $ip\n" if exists $ip_addr{$ip}; # note dupes

   $ip_addr{$ip} = $name;  # index host name by IP address in DB file
[ and so forth....]
}

untie %ip_addr;   # close DB file

# code sample ends
# this is ALL the code which references NDBM_File

My questions (finally) are:

1. Is NDBM_File a complete module, and so I should continue trying to
get it working ?? This
   implies that my system is somehow misconfigured or missing pieces.
That is, are other
   people using this module without having to hack stuff in? That is, am
I barking up an
   obsolete or unsupported tree?

2. Is there a different, alternate, *DBM module I should be using under
Solaris 2.5?

3. What is the library which supports SDBM_File, which the docs say "is
always there"? I
   have R the F docs and they are let's say, scattered, when referring
to implementation
   details of *DBM stuff.

--
John Strickler --  Perl/UNIX/C Trainer, Consultant
Jeffersonian Consortium            Voice:     919-682-3401     
HTTP://WWW.JCINC.COM               Facsimile: 919-682-3369


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

Date: Tue, 18 Mar 1997 20:25:29 +0100
From: Thomas Buehner <buehner@pfaffenhofen.netsurf.de>
Subject: Lost backslash
Message-Id: <VA.0000006c.004d5459@intersco.intersolv.de>

When I run this script:

 $test = '\.\\test';
 print $test;
 
what gets printed is: \.\test

I am confused. What I expected to get was: \.\\test, maybe .\test, if my 
understanding of Perl had been wrong, but \.\test?

The Perl version on which I tested is 5.001m (build 105) for Windows.

Thomas Buehner




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

Date: Tue, 18 Mar 1997 20:25:23 +0100
From: Thomas Buehner <buehner@pfaffenhofen.netsurf.de>
Subject: Re: Q: Good Perl Book
Message-Id: <VA.0000006b.004d3d36@intersco.intersolv.de>

Take a look at http://www.perl.com/perl/critiques/. I have three of the 
books now, and I can say the the reviews hit the mark quite well, though 
I personally find Interactive Course rated too high (bought it before I 
read the reviews).

If you have some programming background, I would suggest you get a copy 
of Programming Perl 2nd ed. Clear language, clear thoughts, clear 
layout, easy to read and search.

Thomas Buehner




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

Date: 18 Mar 1997 20:10:28 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Reg. expression question
Message-Id: <5gmsrk$fh5$1@news.netusa.net>

Devin Ben-Hur  <dbenhur@egames.com> wrote:
>Matt Bieber wrote:
>> I'm trying to weed out any string that contains anything other than:
>> a-zA-Z0-9_, .'s, or @
>> And isn't formatted ____@____

I am going to be generous and assume you don't want it for filtering email
addresses, because that specification is woefully inadequate for email.

if ( $address =~ /^[a-zA-Z0-9_, .]+\@[a-zA-Z0-9_, .]+$/ ) {
  # keep
} else {
  # reject
}

 ...
>if ($email =~ m/[^A-Za-z0-9\@\.+%#!_\-]/ or # invalid chars or
>    $email !~ m/^[^\@]+\@[^\@]+\.[^\@]+$/   # not user@site.domain
 ...
>It isn't perfect, but I haven't had any complaints from
>people.

Probably because that poor coding ate their mail. Here's the
BNF from RFC822. Please study it, esp. the addr-spec chain,
before trying again.

     address     =  mailbox                      ; one addressee
                 /  group                        ; named list
     addr-spec   =  local-part "@" domain        ; global address
     ALPHA       =  <any ASCII alphabetic character>
                                                 ; (101-132, 65.- 90.)
                                                 ; (141-172, 97.-122.)
     atom        =  1*<any CHAR except specials, SPACE and CTLs>
     authentic   =   "From"       ":"   mailbox  ; Single author
                 / ( "Sender"     ":"   mailbox  ; Actual submittor
                     "From"       ":" 1#mailbox) ; Multiple authors
                                                 ;  or not sender
     CHAR        =  <any ASCII character>        ; (  0-177,  0.-127.)
     comment     =  "(" *(ctext / quoted-pair / comment) ")"
     CR          =  <ASCII CR, carriage return>  ; (     15,      13.)
     CRLF        =  CR LF
     ctext       =  <any CHAR excluding "(",     ; => may be folded
                     ")", "\" & CR, & including
                     linear-white-space>
     CTL         =  <any ASCII control           ; (  0- 37,  0.- 31.)
                     character and DEL>          ; (    177,     127.)
     date        =  1*2DIGIT month 2DIGIT        ; day month year
                                                 ;  e.g. 20 Jun 82
     dates       =   orig-date                   ; Original
                   [ resent-date ]               ; Forwarded
     date-time   =  [ day "," ] date time        ; dd mm yy
                                                 ;  hh:mm:ss zzz
     day         =  "Mon"  / "Tue" /  "Wed"  / "Thu"
                 /  "Fri"  / "Sat" /  "Sun"
     delimiters  =  specials / linear-white-space / comment
     destination =  "To"          ":" 1#address  ; Primary
                 /  "Resent-To"   ":" 1#address
                 /  "cc"          ":" 1#address  ; Secondary
                 /  "Resent-cc"   ":" 1#address
                 /  "bcc"         ":"  #address  ; Blind carbon
                 /  "Resent-bcc"  ":"  #address
     DIGIT       =  <any ASCII decimal digit>    ; ( 60- 71, 48.- 57.)
     domain      =  sub-domain *("." sub-domain)
     domain-literal =  "[" *(dtext / quoted-pair) "]"
     domain-ref  =  atom                         ; symbolic reference
     dtext       =  <any CHAR excluding "[",     ; => may be folded
                     "]", "\" & CR, & including
                     linear-white-space>
     extension-field =
                   <Any field which is defined in a document
                    published as a formal extension to this
                    specification; none will have names beginning
                    with the string "X-">
     field       =  field-name ":" [ field-body ] CRLF
     fields      =    dates                      ; Creation time,
                      source                     ;  author id & one
                    1*destination                ;  address required
                     *optional-field             ;  others optional
     field-body  =  field-body-contents
                    [CRLF LWSP-char field-body]
     field-body-contents =
                   <the ASCII characters making up the field-body, as
                    defined in the following sections, and consisting
                    of combinations of atom, quoted-string, and
                    specials tokens, or else consisting of texts>
     field-name  =  1*<any CHAR, excluding CTLs, SPACE, and ":">
     group       =  phrase ":" [#mailbox] ";"
     hour        =  2DIGIT ":" 2DIGIT [":" 2DIGIT]
                                                 ; 00:00:00 - 23:59:59
     HTAB        =  <ASCII HT, horizontal-tab>   ; (     11,       9.)
     LF          =  <ASCII LF, linefeed>         ; (     12,      10.)
     linear-white-space =  1*([CRLF] LWSP-char)  ; semantics = SPACE
                                                 ; CRLF => folding
     local-part  =  word *("." word)             ; uninterpreted
                                                 ; case-preserved
     LWSP-char   =  SPACE / HTAB                 ; semantics = SPACE
     mailbox     =  addr-spec                    ; simple address
                 /  phrase route-addr            ; name & addr-spec
     message     =  fields *( CRLF *text )       ; Everything after
                                                 ;  first null line
                                                 ;  is message body
     month       =  "Jan"  /  "Feb" /  "Mar"  /  "Apr"
                 /  "May"  /  "Jun" /  "Jul"  /  "Aug"
                 /  "Sep"  /  "Oct" /  "Nov"  /  "Dec"
     msg-id      =  "<" addr-spec ">"            ; Unique message id
     optional-field =
                 /  "Message-ID"        ":"   msg-id
                 /  "Resent-Message-ID" ":"   msg-id
                 /  "In-Reply-To"       ":"  *(phrase / msg-id)
                 /  "References"        ":"  *(phrase / msg-id)
                 /  "Keywords"          ":"  #phrase
                 /  "Subject"           ":"  *text
                 /  "Comments"          ":"  *text
                 /  "Encrypted"         ":" 1#2word
                 /  extension-field              ; To be defined
                 /  user-defined-field           ; May be pre-empted
     orig-date   =  "Date"        ":"   date-time
     originator  =   authentic                   ; authenticated addr
                   [ "Reply-To"   ":" 1#address] )
     phrase      =  1*word                       ; Sequence of words
     qtext       =  <any CHAR excepting <">,     ; => may be folded
                     "\" & CR, and including
                     linear-white-space>
     quoted-pair =  "\" CHAR                     ; may quote any char
     quoted-string = <"> *(qtext/quoted-pair) <">; Regular qtext or
                                                 ;   quoted chars.
     received    =  "Received"    ":"            ; one per relay
                       ["from" domain]           ; sending host
                       ["by"   domain]           ; receiving host
                       ["via"  atom]             ; physical path
                      *("with" atom)             ; link/mail protocol
                       ["id"   msg-id]           ; receiver msg id
                       ["for"  addr-spec]        ; initial form
                        ";"    date-time         ; time received

     resent      =   resent-authentic
                   [ "Resent-Reply-To"  ":" 1#address] )
     resent-authentic =
                 =   "Resent-From"      ":"   mailbox
                 / ( "Resent-Sender"    ":"   mailbox
                     "Resent-From"      ":" 1#mailbox  )
     resent-date =  "Resent-Date" ":"   date-time
     return      =  "Return-path" ":" route-addr ; return address
     route       =  1#("@" domain) ":"           ; path-relative
     route-addr  =  "<" [route] addr-spec ">"
     source      = [  trace ]                    ; net traversals
                      originator                 ; original mail
                   [  resent ]                   ; forwarded
     SPACE       =  <ASCII SP, space>            ; (     40,      32.)
     specials    =  "(" / ")" / "<" / ">" / "@"  ; Must be in quoted-
                 /  "," / ";" / ":" / "\" / <">  ;  string, to use
                 /  "." / "[" / "]"              ;  within a word.
     sub-domain  =  domain-ref / domain-literal
     text        =  <any CHAR, including bare    ; => atoms, specials,
                     CR & bare LF, but NOT       ;  comments and
                     including CRLF>             ;  quoted-strings are
                                                 ;  NOT recognized.
     time        =  hour zone                    ; ANSI and Military
     trace       =    return                     ; path to sender
                    1*received                   ; receipt tags
     user-defined-field =
                   <Any field which has not been defined
                    in this specification or published as an
                    extension to this specification; names for
                    such fields must be unique and may be
                    pre-empted by published extensions>
     word        =  atom / quoted-string
     zone        =  "UT"  / "GMT"                ; Universal Time
                                                 ; North American : UT
                 /  "EST" / "EDT"                ;  Eastern:  - 5/ - 4
                 /  "CST" / "CDT"                ;  Central:  - 6/ - 5
                 /  "MST" / "MDT"                ;  Mountain: - 7/ - 6
                 /  "PST" / "PDT"                ;  Pacific:  - 8/ - 7
                 /  1ALPHA                       ; Military: Z = UT;
     <">         =  <ASCII quote mark>           ; (     42,      34.)


Note that comments can nest and therefore cannot be matched
correctly for the general case by perl RE's.

Elijah
------
in practice I doubt you'll see too much nesting


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

Date: Tue, 18 Mar 1997 12:03:24 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: Fapso Marek <fapsom@hron.fei.tuke.sk>
Subject: Re: Split
Message-Id: <332EF50C.51C1@egames.com>

[mail&post]
Fapso Marek wrote:
> $tmp="a|||b|||";
> @li=split('\|',$tmp);
>         This program split string into array with size only 4.  Why?

read Camel p.220
specifically:
   If LIMIT is omitted, trailing null fields are stripped
   from the result.

--
Devin Ben-Hur      <dbenhur@egames.com>
eGames.com, Inc.   http://www.egames.com/
eMarketing, Inc.   http://www.emarket.com/
"Sometimes you just have to step in it and see if it stinks"  O-
    -- Sonia Orin Lyris



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

Date: 18 Mar 1997 13:38:33 -0800
From: bruceb@janus.la.platsol.com (Bruce M. Binder)
Subject: Re: What's wrong with "an email"
Message-Id: <5gn20p$r5r@janus.la.platsol.com>

Matt Kruse  <mkruse@shamu.netexpress.net> wrote:

> Tom Christiansen <tchrist@mox.perl.com> wrote:

> > I have come to believe that the linguistic dissonance
> > we're experiencing is rooted in this: that the American
> > mass media, ...  have unknowingly mangled an established
> > term.

> With all due respect, I think that's a bunch of bull.  I
> work with highly technical people, and some of them 'send
> out a few emails to the group'.  It's just a different way
> to use the term.  Evolution of language - it happens all the
> time.

I disagree.  Certainly the language changes.  But many changes
started out as an error that came to be accepted.  Far more
errors are not accepted and never cause a change in the
language.  I think were still at the stage where this is not
"just a different way to use the term".  It's an error.  Why
should this particular error be accepted merely because lazy
users hide behind the "evolution of the language" argument?

<bruceb>
 ___  __  __  ___ 
(  ,)(  \/  )(  ,)  Bruce M. Binder <bruceb@platsol.com.nospam>
 ) ,\ )    (  ) ,\  PLATINUM Solutions      tel: (619) 546-9509
(___/(_/\/\_)(___/  San Diego, California  Plat. extension 3959


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

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

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed 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 V8 Issue 140
*************************************

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