[6333] in Perl-Users-Digest
Perl-Users Digest, Issue: 955 Volume: 7
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 15 10:17:25 1997
Date: Sat, 15 Feb 97 07:00:24 -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: 955
Today's topics:
Re: "scalar each" - what does it mean? (Tad McClellan)
Re: CGI.pm TABLEs help please <cobled@cyberspace.com>
difference btw s/// & tr/// <fkong@scf.usc.edu>
Re: difference btw s/// & tr/// (Honza Pazdziora)
Re: difference btw s/// & tr/// (Tad McClellan)
Re: difference btw s/// & tr/// <ajohnson@gpu.srv.ualberta.ca>
Re: difference btw s/// & tr/// <ajohnson@gpu.srv.ualberta.ca>
File Locking <menger@mindless.com>
Re: File Locking (Honza Pazdziora)
Re: File write permissions in Perl (Nathan V. Patwardhan)
Financial Aid <jmlittl@clemson.edu>
ftp in perl <roy.donnelly@aetna.com>
Re: ftp in perl (Honza Pazdziora)
Re: Help in setting up S/// <ajohnson@gpu.srv.ualberta.ca>
Re: Help w/ distributing perl app? (Paul Marquess)
Re: How can I create associative arrays from variables? (Honza Pazdziora)
Re: Need help - just starting perl (Frans Postma)
New Pod:: modules in pre-Alpha; opinions sought <eryq@enteract.com>
Re: Path to a file handle (Andrew M. Langmead)
Re: Perl script debug help (Tad McClellan)
Re: QUES: what is "undump"? (Nathan V. Patwardhan)
Regexp to do minimal email validation (Jon Drukman)
Re: Regexp to do minimal email validation (Honza Pazdziora)
Re: Regular Expressions and Assigning to Variable (Michael Nelson)
SMNP Problem (WinNT) <jimmy@cil.qc.ca>
Uploading files in perl4 !! jrduval@total.net
Re: what does this line do? (Lutz Albers)
Re: why can't "system" return a long? (Donald H. Locker)
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 15 Feb 1997 08:16:18 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: "scalar each" - what does it mean?
Message-Id: <ifg4e5.is.ln@localhost>
Brett McCormick (brett@speedy.speakeasy.org) wrote:
: Hmmm, interesting.. I was unaware that there was a difference between
^^^^^^^^^^^^^^^^^^
: arrays and lists.. I assume that a list is one or more perl types,
^^^^^^^^^^^^^^^^^
: where as an array is a perl type (which happens to contain 0 or more
: other perl types?_
Tom has corrected me on this point before, so now I can, in turn,
correct others ;-)
For example, the perlfunc man page says: push ARRAY,LIST
They (the clever people who work on the perl executable) wouldn't
distinguish between them if they were the same.
push(@ra, "foobar"); # sensible
^^^ ARRAY
push( ('item1', 'item2'), "foobar"); # huh! where should it push it?
^^^^^^^^^^^^^^^^^^ LIST
'zat help?
: 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
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Fri, 14 Feb 1997 17:57:17 -0800
From: David Lloyd Coble <cobled@cyberspace.com>
Subject: Re: CGI.pm TABLEs help please
Message-Id: <330517FD.7A35@cyberspace.com>
David Coble wrote:
>
> According to the documentation in
> http://www-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html#html
> HTML3 table tags should work like any other matched-pair tag, e.g.:
>
> print table(
> TR( #note capitalization to avoid conflict with translate
> td("One"),
> td("Two")
> ),
> TR(
> td("Three"),
> td("Four")
> )
> );
>
> This code fragment (assuming use CGI ':standard') seems like it should
> make output like:
>
> <TABLE> <TR> <TD>One</TD> <TD>Two</TD>
> <TR> <TD>Three</TD> <TD>Four</TD>
> </TABLE>
>
> But it doesn't. I have smashed my head against this one for several
> hours. I can't get $query->table to give me any output whatever. If
> anyone has the solution to this one, I'd love to hear it
>
> --Dave Coble --
> --cobled@cyberspace.com--
------------------------------
Date: 14 Feb 1997 23:07:44 -0800
From: Elton Kong <fkong@scf.usc.edu>
Subject: difference btw s/// & tr///
Message-Id: <Pine.SV4.3.94.970214230429.20910A-100000@aludra.usc.edu>
Hi!
I'm fairly new to PERL. Could anybody tell me what's the
difference between using the s/// and the tr/// operators. I mean
when I should use one and when the other. When both are good,
what's the philosophy to choose one over the other? Thanks
Elton
--
Elton Kong
mailto:fkong@scf.usc.edu
http://www-scf.usc.edu/~fkong/
------------------------------
Date: Sat, 15 Feb 1997 11:56:10 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: difference btw s/// & tr///
Message-Id: <adelton.856007770@aisa.fi.muni.cz>
Elton Kong <fkong@scf.usc.edu> writes:
> Hi!
> I'm fairly new to PERL. Could anybody tell me what's the
> difference between using the s/// and the tr/// operators. I mean
> when I should use one and when the other. When both are good,
> what's the philosophy to choose one over the other? Thanks
Both are good and you choose the proper one accoring to your needs.
s/// finds substring and _substitutes_ with another string
(basically). tr/// _trensforms_ each character of the string into some
other. See the difference?
Perl man pages, FAQ and Camel book will help you more.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: Sat, 15 Feb 1997 08:26:42 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: difference btw s/// & tr///
Message-Id: <23h4e5.is.ln@localhost>
Elton Kong (fkong@scf.usc.edu) wrote:
: Hi!
: I'm fairly new to PERL. Could anybody tell me what's the
: difference between using the s/// and the tr/// operators. I mean
: when I should use one and when the other. When both are good,
: what's the philosophy to choose one over the other? Thanks
these are both explained in the perlop man page that is included
with the perl distribution.
Is there some part of the explanations given there that you don't
understand? If so, what part?
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Sat, 15 Feb 1997 03:26:38 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: difference btw s/// & tr///
Message-Id: <3305814E.5F9BE946@gpu.srv.ualberta.ca>
Elton Kong wrote:
>
> Hi!
> I'm fairly new to PERL. Could anybody tell me what's the
> difference between using the s/// and the tr/// operators. I mean
> when I should use one and when the other. When both are good,
> what's the philosophy to choose one over the other? Thanks
check the perlop manpage and the perlre manpage.
s/// uses regexes and does subsitutions on matches
tr/// does not use regexes and does translations from, say
lowercase to uppercase
andrew
------------------------------
Date: Sat, 15 Feb 1997 03:28:27 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: difference btw s/// & tr///
Message-Id: <330581BB.400761D1@gpu.srv.ualberta.ca>
Elton Kong wrote:
>
> Hi!
> I'm fairly new to PERL. Could anybody tell me what's the
> difference between using the s/// and the tr/// operators. I mean
> when I should use one and when the other. When both are good,
> what's the philosophy to choose one over the other? Thanks
check the perlop manpage and the perlre manpage.
s/// uses regexes and does subsitutions on matches
tr/// does not use regexes and does translations from, say
lowercase to uppercase
andrew
------------------------------
Date: 15 Feb 1997 10:44:47 GMT
From: "Matthew Enger" <menger@mindless.com>
Subject: File Locking
Message-Id: <01bc1b2d$17fbfdc0$171f55ca@menger.enger.dyn.ml.org>
Hello,
I want to be able to lock a file up so 2 people don't access it at the
same time. Can anyone help?
from,
Matthew Enger
menger@mindless.com
------------------------------
Date: Sat, 15 Feb 1997 12:12:26 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: File Locking
Message-Id: <adelton.856008746@aisa.fi.muni.cz>
"Matthew Enger" <menger@mindless.com> writes:
> Hello,
> I want to be able to lock a file up so 2 people don't access it at the
> same time. Can anyone help?
Yes. There is a really nice example in
man perlfunc
Check for flock.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: 15 Feb 1997 06:57:28 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: File write permissions in Perl
Message-Id: <5e3moo$dhe@fridge-nf0.shore.net>
Jay Jacobs (jjacobs@incnet.com) wrote:
: I am trying to create an HTML form to update news stories on a company
: web site. I have most everything written, but the only way I can get it
: to write to a file (in perl from a script) is by opening up the
[snip].
To put you on the right track, three things:
(1) If you're running a Unix server, the answer is, "yes" you can make
the file non-world-writable. Caveat: I think you have to be running
your server as a user other than "nobody," someone who has permissions
to write a working area. This opens up its own can of worms.
(2) This question has nothing to do with perl, but servers - why did you
post it in this NG?
(3) Please re-direct any more non-Perl-specific questions to
comp.infosystems.www.servers.misc
HTH!
--
Nathan V. Patwardhan
nvp@shore.net
"send me mail"
--Jamie Zawinski
------------------------------
Date: Sat, 15 Feb 1997 01:39:12 -0600
From: John Little <jmlittl@clemson.edu>
Subject: Financial Aid
Message-Id: <33056820.5290@clemson.edu>
If you are reading this now, you, like me, are
badly in need of money. Believe me, I understand.
If the United States had debtor's prison, I'd have
been in it years ago. However, there is a way out.
All you have to do is use the follow program.
You can make HUNDREDS, if not THOUSANDS OF DOLLARS.
Mail a single dollar bill to each of the following
people, along with a note which says:
"Please add me to your list. My name
and address is (include your name and address)."
(1) Ralph
7439 Hwy 70 S. #268
Nashville, Tn. 37221
(2) Bob Sullivan
4553 Atascadero Dr.
Santa Barbara, Ca. 93110
(3) Bill Gray
8114 SW 104th Way
Gainesville, FL 32608
(4) Y. Yuksel
1561 Mesa Dr. #123
Santa Ana, CA 92707
(5) J. M. Little
Clemson University
P.O. Box 3669
Clemson, SC 29632-3669
Then copy this message, and re-post it to as many
newsgroups as you can, but with the following changes:
Erase the first person's address.
Move each of the remaining addresses up one number.
(#2 becomes #1, #3 becomes #2, etc.)
Add your name and address as the fifth one.
What will happen is this. Others who, like you, are
in need of money, will read your message, just as
you are reading this one, and decide that they need
the extra cash. They will send you their one dollar
bill, and repost the message, making the same changes
you did. You will still be on the list as #4. Someone
will read their message, send money to everyone on the
list, including you, and post another message, making
the changes. You will still be on the list as #3. This
will continue until you are off the list, but by the time
you are off the list, AT LEAST five people will send you
money. There's the five dollars you sent. I cannot
confirm them, but there are continuous statements about
how people have made hundreds, thousands, and even tens
of thousands of dollars with this plan. Remember, the
more places you put this, the more money you make.
Does this seem unreasonable? It shouldn't. There are
millions of people in the United States just like you,
who need money, and are looking for a solution.
Thousands of people are getting on the internet for the
first time, every day, and each of them wants to make
money. Is it so unbelievable that they, like you, will
follow this plan, hoping for a big return? At most, it
will cost you ten dollars: one dollar for each person,
and five for the pen, stamps, and envelopes.
Is it impossible for you to imagine there are ten people
somewhere in America who want to make money?
If there are, then you've only lost a little time. But
in fact, there are MILLIONS of people who NEED the money,
and they are looking for ANY chance to make some. You
will more than make up for any time or money you spend.
Is this program illegal? No. There's nothing illegal, or
even shady, about this. Do you want proof?
1. The inclusion of the message "Add my name to your
list." makes this a service, just like any TV
advertisement or 1-900 number. Are those illegal?
2. Does the federal government police the internet? No.
Do they open your mail? No. THAT would be illegal.
3. If this were illegal, do you really think I'd be dumb
enough to give the police my address?
Please, support this program. There is the potential for
both you and I to make a LOT of money together. Thank you.
------------------------------
Date: Fri, 14 Feb 1997 12:42:22 -0500
From: "Roy C. Donnelly" <roy.donnelly@aetna.com>
Subject: ftp in perl
Message-Id: <3304A3FE.5B05@aetna.com>
I'm looking to do an ftp put programmatically in perl and I'm not sure
of the most efficient way to do so. Any suggestions/examples?
------------------------------
Date: Sat, 15 Feb 1997 14:37:11 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: ftp in perl
Message-Id: <adelton.856017431@aisa.fi.muni.cz>
"Roy C. Donnelly" <roy.donnelly@aetna.com> writes:
> I'm looking to do an ftp put programmatically in perl and I'm not sure
> of the most efficient way to do so. Any suggestions/examples?
And what documentation have you already read? Is man Net::FTP not
enough? There are both "suggestions/examples".
Hope this helps.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: Sat, 15 Feb 1997 03:11:38 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Help in setting up S///
Message-Id: <33057DCA.5804555D@gpu.srv.ualberta.ca>
Honza Pazdziora wrote:
! Andrew Johnson <ajohnson@gpu.srv.ualberta.ca> writes:
!
! > :
! > : s/(\s+)\*(\s+)/\1 \2/
! > :
! > : Keith Arner
! >
! > better with:
! > s/(\s+)\*(\s+)/$1 $2/;
!
! And wouldn't s/^(\s+?)\*(\s+?)/$1 $2/; be more correct and faster?
!
you are quite correct on anchoring the pattern to the beginning
of the string, i was more focused on the use of \1 instead of
$1 in the substitution, and didn't pay attention to the front.
However, your use of non-greedy quantifiers would be less efficient
in this case, as the engine would have to jump out of the
parentheses after matching each \s to see if it had a minimal
number before hitting the asterisk. in quick test on a file with
half the lines containing the * and half not (he said it was
optional after all), using (\s+) instead of (\s+?) runs about
20% faster. (this file had 10 spaces before optional *, more spaces
would slow your version down further).
also, we don't really need the second (\s+) and $2 at all do we?
andrew
------------------------------
Date: 15 Feb 1997 12:26:16 GMT
From: pmarquess@bfsec.bt.co.uk (Paul Marquess)
Subject: Re: Help w/ distributing perl app?
Message-Id: <5e4a18$ah7@pheidippides.axion.bt.co.uk>
[ Posted & Mailed]
Aimee Schneider (aimee@interport.net) wrote:
: Hey all,
: Has anyone out there written a commercial app, or parts thereof, in perl
: and distributed it? My problem is that I want to distribute this app, but
: not the source. I know, it shouldn't have been written in perl in the
: first place, but it's too late to rewrite it now. From what I understand,
: my options are (from the FAQ, Q3.5):
: 1. Obfuscate it
: 2. Use cryptswitch()
: 3. Include a disclaimer at the top of each file
: or
: 4. Use the perl compiler to turn it into C or bytecode
: Options 1 and 3 are pretty much out of the question. I tried using the
: perl compiler and actually had a little success. The problem: it worked
: (bytecode) on sparc, but it needs to work on NT. I'm going to spend
: another day trying to port it (the compiler) but it's giving me a real
: headache.
: Now... I'm interested in cryptswitch(), but I didn't see any
: documentation for it. It's only briefly mentioned in the 'Changes' file
: that comes with the source dist. Anyone have any info on this?
: Also, anyone ever use the Filter module?
If you are using Perl 5, cryptswitch has been superceeded by the Filter
module. The FAQ is out of date in this respect.
I know of a few people who distribute applications that make use of the
decrypt filter.
Paul
------------------------------
Date: Sat, 15 Feb 1997 11:25:20 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: How can I create associative arrays from variables?
Message-Id: <adelton.856005920@aisa.fi.muni.cz>
Noemi Preissner <noemi@coli.uni-sb.de> writes:
> Hi,
>
> the answer might be easy, but after having tried a lot of
> things I feel quite helpless now:
>
> How can I create an associative array from variables, i.e.
> if I have a variable $1 with value x and another variable $2
> with value y, I would like to create an associative array
> named after the value of $1 (%x) with the value of $2 as one
> of its keys ...
>
> What can I write instead of
>
> $x{y} = "yes";
>
> I am interested in something like ${$2}{$1} = "yes";
> (which obviously is not the right way to do it ... )
I might be answering something else than you are asking, but code
$a = "x";
$b = "y";
eval " \$${a}{$b} = 'yes'; ";
print $x{y}, "\n";
should print yes for you. If you give print " \$${a}{$b} = 'yes'; "
instead of eval, it shows $x{y} = 'yes'; and that's what you asked
for, right?
Hope this helps.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: Sat, 15 Feb 1997 10:48:11 GMT
From: F.Postma@inter.NL.net (Frans Postma)
Subject: Re: Need help - just starting perl
Message-Id: <33058940.4956427@news.Nl.net>
"robert@tnet.es" <robert@tnet.es> wrote:
>I am trying to get perl 5 running on a Sparc 5 with solaris 2.5 .I get the
>following error in the configure and make
>
>make: Warning: Both `makefile' and `Makefile' exist
You're sure you running a clean configure? (you did extract the tar
file to a new directory which didn't exist before you 'tar xvf' it?)
Looks like a "make clean;make realclean;rm config.sh" might help, at
least it will rerun configure (which didn't manage to find 'ar' it
seems)
Good luck.
Frans Postma
(fpostma@inter.nl.net)
------------------------------
Date: Sat, 15 Feb 1997 04:09:21 -0600
From: Eryq <eryq@enteract.com>
Subject: New Pod:: modules in pre-Alpha; opinions sought
Message-Id: <33058B51.459A692A@enteract.com>
I've developed 3 new Pod:: modules which I think might be very
nice additions to the Pod:: family. If you've got the inclination,
please send me your opinions on the following:
Pod::Label parse L<> labels, extracting page, title,
and type. Even handles intuitive-
but-nonstandard constructs like
L<open()> and L<$Module::var>.
Pod::TopDown subclass of Pod::Parser that does top-down
expansion of x<> markup, plus some nice
=over/=item/=back bookkeeping
Pod::CoolHTML subclass of Pod::TopDown, a 2-pass
converter to create real cool HTML,
allowing you LOTS of options which can
be placed in config files. Example?
see the docs (URL below)
The Pod::CoolHTML module was used to generate the on-line
documentation, which you can see at:
http://www.enteract.com/~eryq/CPAN/Pod/CoolHTML.pm.html
(Actually, the module was used to build "pod2coolhtml", which did
the work.)
If you'd like to see this stuff in the CPAN, or if not, or
if you have some suggestions as to how they can be improved (this
is pre-Alpha code after all; I've currently got the only copy, so the
sky's the limit as far as changing stuff), please email me and let
me know.
TIA,
--
___ _ _ _ _ ___ _ Eryq (eryq@enteract.com)
/ _ \| '_| | | |/ _ ' / Hughes STX, NASA/Goddard Space Flight Cntr.
| __/| | | |_| | |_| | http://www.mcs.net/~eryq
\___||_| \__, |\__, |__
|___/ |___/ Make $$$ easy! Just hit shift, then 444!
------------------------------
Date: Sat, 15 Feb 1997 13:53:54 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Path to a file handle
Message-Id: <E5nD9u.45D@world.std.com>
Todd Lowpensky <toddl@net.com> writes:
>I'm trying to find the complete path to a specific
>file handle that I am operating on. I am using Solaris,
>and Perl 5. The STATS command appears to give me everything
>I might possibly want about a file EXCEPT the path.
The answer to that isn't in the Perl FAQ, but it is in the Unix FAQ:
>4.3) How do I find the name of an open file?
>
> In general, this is too difficult. The file descriptor may
> be attached to a pipe or pty, in which case it has no name.
> It may be attached to a file that has been removed. It may
> have multiple names, due to either hard or symbolic links.
>
> If you really need to do this, and be sure you think long
> and hard about it and have decided that you have no choice,
> you can use find with the -inum and possibly -xdev option,
> or you can use ncheck, or you can recreate the functionality
> of one of these within your program. Just realize that
> searching a 600 megabyte filesystem for a file that may not
> even exist is going to take some time.
--
Andrew Langmead
------------------------------
Date: Sat, 15 Feb 1997 08:21:40 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Perl script debug help
Message-Id: <kpg4e5.is.ln@localhost>
Dave Thomas (dave@fast.thomases.com) wrote:
: On Thu, 13 Feb 1997 14:07:38, RKing <rking@thepoint.net> wrote:
: > #!/usr/bin/perl -w
: ....
: > I went and put it in at the top of my script, just as it apears
: > above. THEN when I do ./program, I get a message that says "no such file or
: > directory" Am I using it wrong? I'm using unix and perl v. 4. (036
: > I think).
: Perl is probably not in /usr/bin/perl. Its a very stupid Unix error message,
: reported when you have a #! line reference a command interpreter that
: doesn;t exist.
: You may be able to type 'which perl' to find the correct path (or just look
: in each of the directories in your $PATH.
I have seen a variation of this problem, that took quite some time
to figure out.
On a (poorly administered) site that I used to use, /usr/bin/perl
_did_ exist when I got this message. It turned out that it was a
symbolic link (a 'chain' of them actually). One of the links in the
chain pointed to a sym link that had been 'rm'ed. Stoopid...
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 15 Feb 1997 06:52:29 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: QUES: what is "undump"?
Message-Id: <5e3mfd$dhe@fridge-nf0.shore.net>
John Nolan (sg94bwh5@dunx1.ocs.drexel.edu) wrote:
: In Programming Perl (2nd ed, page 336), they mention in passing
: that you can take the coredump of a compiled perl script,
: "undump" it using the undump program, and create an
: executable. Does anyone know what undump is?
Undump is a nightmare that should be avoided. :-) Seriously, undump
is/was included with either TeX or LaTeX (you can confirm which package
by doing an internet search for undump). If I'm correct, assuming
that undump works with your distribution (and with you OS), you pass
Perl an argument which causes execution of your script to dump core.
Then you run undump on your core file. If you undump the "hello world"
program, it will be 300K. Imagine the executable for something signifcant?
You're better off checking out the Perl compiler, available at a CPAN
near you!
HTH.
--
Nathan V. Patwardhan
nvp@shore.net
"send me mail"
--Jamie Zawinski
------------------------------
Date: 15 Feb 1997 00:36:19 GMT
From: jsd@cyborganic.com (Jon Drukman)
Subject: Regexp to do minimal email validation
Message-Id: <5e30e3$eh4@its.hooked.net>
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\.]+/
(the string in question is already lowercased so A-Z can safely be
ignored)
this is problematic because it allows multiple periods in a row.
(jsd@some...where.com is just fine).
how can i say "periods are only allowed if the preceding character was
a-z0-9"? i thought perhaps some variant of the grouping (:? )
expression would do it but i am stumped.
-jon
------------------------------
Date: Sat, 15 Feb 1997 12:04:12 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Regexp to do minimal email validation
Message-Id: <adelton.856008252@aisa.fi.muni.cz>
jsd@cyborganic.com (Jon Drukman) 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 gurus would answer you should really use some module for it and
not reinvent the wheel.
> the best i could come up with was:
>
> /^\w+@[a-z0-9][\w\.]+/
>
> (the string in question is already lowercased so A-Z can safely be
> ignored)
>
> this is problematic because it allows multiple periods in a row.
> (jsd@some...where.com is just fine).
>
> how can i say "periods are only allowed if the preceding character was
> a-z0-9"? i thought perhaps some variant of the grouping (:? )
> expression would do it but i am stumped.
This solution checks for a dot that must be preceded by a \w but I
would not recommend it for e-mail address checking.
/^\w+@[a-z0-9](\w\.?)+$/
Is that enough?
And BTW, there is a module to parse e-mail address :-)
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: 15 Feb 1997 11:22:59 GMT
From: nelson@seahunt.imat.com (Michael Nelson)
Subject: Re: Regular Expressions and Assigning to Variable
Message-Id: <slrn5gb74j.794.nelson@seahunt.imat.com>
On 15 Feb 1997 04:41:01 GMT, Michael Nelson <nelson@seahunt.imat.com> wrote:
>Hi...
>
>I'm writing a small program to parse some data out of a web page
>and then print it out in another form. My problem is this... I
>need to find lines of the form:
Nevermind....;-) I figured it out.
Michael
--
=================================================================
Michael Nelson nelson@seahunt.imat.com
San Francisco, CA michaeln@csd.sgi.com
"I don't want to achieve immortality through my work, I want
to achieve immortality by not dying." - Woody Allen
=================================================================
------------------------------
Date: Sat, 15 Feb 1997 06:06:21 -0500
From: Jimmy Beattie <jimmy@cil.qc.ca>
Subject: SMNP Problem (WinNT)
Message-Id: <330598AD.1E@cil.qc.ca>
I try to use the following PERL program to send form data to an eMail
address. All things seem to work well but the targetted (eMail) user or
the REPLYTO user never receive anything.
The script correctly display the "Thanks page" after the SUBMIT button
is clicked. I don't receive any SMNP error from errorhandler@myhost.com
I'm using PERL5 with WINDOWS NT. It's my first PERL program, but I
can't figure out why this is not working properly. Could you help me?
#!/bin/perl
# SMTPMAIL.PL
# by Robin S Chatterjee
# This is a script I cobbled together from the tcp Examples.
# It is meant to replace MAILER.CGI on NT servers which have access to
Unix
# SMTP servers on the network.
# USAGE
# You use this script my putting special fields into your HTML form.
# They are as follows:
#
# <INPUT TYPE="HIDDEN" NAME="TO" VALUE="you@your.site.com">
# Who to send the results to. Multiple recipients will work fine.
# <INPUT TYPE="HIDDEN" NAME="SUBJECT" VALUE="Subject Line">
# What the subject should be on the mail message send to recipients
# <INPUT TYPE="HIDDEN" NAME="REPLY-TO" VALUE="name@site.com">
# Who should be listed in the "Reply-To" field of the mail message.
# <INPUT TYPE="HIDDEN" NAME="SMTPHOST" VALUE="smtphost.yourdomain">
# Who should be listed in the Hosts file of the NT server,or have
# a valid DNS entry.
# Inputs do not need to be hidden, but you'll probably want them
# that way.
# The default response to give the user is at the very end.
Anything
# after __END__ will be put up as feedback. Edit as you wish. If you
# would like the responses to be sent in a specific format, you'll have
# to do that on your own.
#
# The CHECK_EMPTIES variable decides whether an error should be returned
# if a field is left blank. If it is set to 1, an error message will
# be displayed. If it is set to 0, blank fields are acceptable.
$CHECK_EMPTIES=1;
# =========================
# END OF USER CONFIGURATION
print "Content-type: text/html\n\n";
sub ReadParse {
# slightly modified from the usual readparse
local (*in) = @_ if @_; local ($i, $loc, $key, $val);
if ($ENV{'REQUEST_METHOD'} eq "GET") { $in = $ENV{'QUERY_STRING'};}
elsif ($ENV{'REQUEST_METHOD'} eq "POST")
{read(STDIN,$in,$ENV{'CONTENT_LENGTH'});}
@in = split(/&/,$in);
foreach $i (0 .. $#in) {
$in[$i] =~ s/\+/ /g; ($key, $val) = split(/=/,$in[$i],2);
$FOUND=0; foreach (@FIELDS) { $FOUND=1 if ($key eq $_); }
if (($key ne 'TO')&&($key ne 'SMTPHOST')&&($key ne 'SUBJECT')&&($key
ne 'REPLY-TO')&&($FOUND==0))
{ push(@FIELDS,$key); }
$key =~ s/%(..)/pack("c",hex($1))/ge;
$val =~ s/%(..)/pack("c",hex($1))/ge;
$in{$key} .= "\0" if (defined($in{$key}));
$in{$key} .= $val; } return 1; }
&ReadParse;
foreach (@FIELDS) {&MissingInfo if (($in{$_} eq
'')&&($CHECK_EMPTIES==1));}
$in{'TO'} ='ROOT' if (!defined $in{'TO'});
$in{'SUBJECT'} ='NO SUBJECT' if (!defined $in{'SUBJECT'});
$in{'REPLY-TO'} ='JIMMY@CIL.QC.CA' if (!defined $in{'REPLY-TO'});
$in{'SMTPHOST'} ='cil.qc.ca' if (!defined $in{'SMTPHOST'});
$ENV{'SERVER_ADDR'} ='cil.qc.ca' if (!defined $ENV{'SERVER_ADDR'});
$SUBJECT=$in{'SUBJECT'}; delete $in{'SUBJECT'};
$REPLYTO=$in{'REPLY-TO'}; delete $in{'REPLY-TO'};
$SMTPHOST=$in{'SMTPHOST'}; delete $in{'SMTPHOST'};
$SERVERNAME=$ENV{'SERVER_NAME'};
$SERVERNAME=$ENV{'SERVER_ADDR'} if(!defined $ENV{'SERVER_NAME'});
# split up the "to" names for multiple recipients
$TO=$in{'TO'}; @TO=split('\0',$TO);
#( $them, $port ) = @ARGV;
$port = 25 unless $port;
$them = $SMTPHOST unless $them;
$AF_INET = 2;
$SOCK_STREAM = 1;
$SIG{'INT'} = 'dokill';
sub dokill {
kill 9,$child if $child;
}
$sockaddr = 'S n a4 x8';
#chop($hostname = `hostname`);
($name,$aliases,$proto) = getprotobyname('tcp');
($name,$aliases,$port) = getservbyname($port,'tcp')
unless $port =~ /^\d+$/;;
($name,$aliases,$type,$len,$thisaddr) =
gethostbyname($hostname);
($name,$aliases,$type,$len,$thataddr) = gethostbyname($them);
$this = pack($sockaddr, $AF_INET, 0, $thisaddr);
$that = pack($sockaddr, $AF_INET, $port, $thataddr);
if (socket(S, $AF_INET, $SOCK_STREAM, $proto)) {
print "socket ok\n";
}
else {
die $!;
}
if (bind(S, $this)) {
print "bind ok\n";
}
else {
die $!;
}
if (connect(S,$that)) {
print "connect ok\n";
}
else {
die $!;
}
select(S); $| = 1; select(STDOUT);
$a=<S>;
#print "$a";
print S "HELO ${SERVERNAME}\n";
$a=<S>;
#print "$a";
print S "MAIL FROM:<SMTPMAIL>\n";
$a=<S>;
#print "$a";
print S "RCPT TO:<@TO[0]>\n";
$a=<S>;
#print "$a";
if ($#TO > 0) { foreach (1..$#TO) { print S "RCPT TO: @TO[$_]\n";$a=<S>;
}
}
print S "DATA \n";
$a=<S>;
print S "To: @TO[0]\n";
if ($#TO > 0) { foreach (1..$#TO) { print S "Cc: @TO[$_]\n"; }
}
print S "Subject: $SUBJECT\n";
print S "Reply-To: $REPLYTO\n";
# Display each field and responses
foreach (@FIELDS) {
$in{$_}=~ s/\0/\n\n * /g;
print S "---------------------------------------------------\n";
print S "Input Field: $_\n";
print S "Response:\n * $in{$_}\n";
}
print S "---------------------------------------------------\n";
print S ".\n";
$a=<S>;
print S "QUIT";
# Read in the response and print it.
undef $/; $_=<DATA>; print;
# What to display as the "missing information" error
sub MissingInfo {
print <<EOF;
<HTML>
<HEAD> <TITLE>Error</TITLE> </HEAD>
<BODY>
<H1 ALIGN=CENTER>Error: Missing data</H1>
<B>
You are required to fill in all the fields in this response form.
Please go back and fill in the fields with missing information.
</B>
EOF
exit(0);
}
# Everything down here is the default response.
__END__
<HTML>
<HEAD> <TITLE>SMTPMAIL TEST 2</TITLE> </HEAD>
<BODY>
<H1 ALIGN=CENTER>Thank you!</H1>
<B> Thanks for responding to this form. Your responses have been
mailed to the correct person.<P>
</B>
</BODY>
</HTML>
--
End of PERL SCRIPT
Jimmy Beattie
eMail: Jimmy@cil.qc.ca
------------------------------
Date: Sun, 09 Feb 1997 23:41:30 -0500
From: jrduval@total.net
Subject: Uploading files in perl4 !!
Message-Id: <32FEA6FA.4D2E@total.net>
I need to upload files from a HTML(CGI) page to my directory. I know the
procedure to take the file from the page but i do not know how to
transfer it to my server. Any help would be greatly welcome
jrduval@total.net
------------------------------
Date: Thu, 13 Feb 1997 10:14:07 +0100
From: lutz@muc.de (Lutz Albers)
Subject: Re: what does this line do?
Message-Id: <lutz-ya023480001302971014070001@news>
In article <5dtim8$788$2@csnews.cs.colorado.edu>, tchrist@mox.perl.com (Tom
Christiansen) wrote:
> [courtesy cc of this posting sent to cited author via email]
>
>In comp.lang.perl.misc,
> writes:
>:I don't understand this line:
>: $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>:it appears in a cgi script. Could someone explain it?
>What man pages did you previously check before your posting? Between
>perlre and perlre for all the pattern stuff, and maybe perlfunc for pack
>and perldata for what variables are, you should be able to figure it out.
:-)
Maybe he just wanted the semantic and posted to the wrong group (a cgi
group would be a better place :-)
Anyway this code decodes quoted characters in a URL string back to the
original characters.
ciao
lutz
--
Lutz Albers, lutz@muc.de
Do not take life too seriously, you will never get out of it alive.
------------------------------
Date: Sat, 15 Feb 1997 12:02:56 GMT
From: dhl@mrdog.msl.com (Donald H. Locker)
Subject: Re: why can't "system" return a long?
Message-Id: <E5n84x.K6C@mrdog.msl.com>
How about having the C program printf the difficult value; then use
backticks rather than system to get the result.
In article <5dftu6$jv5@hecate.umd.edu>, Ellen Paik <epaik@deans.umd.edu> wrote:
>Hello,
>
>Can someone clarify what I need to do in order to get a call to a
>C program using the "system" function to return a value of type long?
>Whenever the program returns an integer larger than type int, the
>return value gets messed up.
--
Donald.
These opinions were formulated by a trained professional.
DO NOT TRY THIS AT HOME!
At the time, the tone will be ... BEEP!
------------------------------
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 955
*************************************