[17285] in Perl-Users-Digest
Perl-Users Digest, Issue: 4707 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 24 03:07:28 2000
Date: Tue, 24 Oct 2000 00: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: <972371111-v9-i4707@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 24 Oct 2000 Volume: 9 Number: 4707
Today's topics:
ActiveState PerlCtrl is TROJAN VIRUS? (remove NOSPAM.)
Connecting directly to rsh daemon <toralf@kscanners.com>
Re: detecting client disconnect (David Efflandt)
Re: Don't use -w in CGI? (brian d foy)
Re: File locking <bart.lateur@skynet.be>
Re: Invalid switch msg on system call harris_m@my-deja.com
New to Perl, Need Help ! msalerno@my-deja.com
Re: On being Schwartz.. (was Re: newbie cgi examples) <nospam.newton@gmx.li>
OT: Jihad definition <jkline@one.net>
Re: Perl:socket connection port 23 flam73@my-deja.com
Re: PerlMagick... (Martien Verbruggen)
Re: Processing an Email (sendmail) attachment with Perl (Martien Verbruggen)
Regular expression help - redefinition of the problem jsfinn@my-deja.com
Re: Regular expression help <godzilla@stomp.stomp.tokyo>
Re: Regular expression help (Sam Holden)
Re: Regular expression help (Craig Berry)
Re: Regular expression help (Craig Berry)
Re: Regular expression help (Craig Berry)
Re: Regular expression help <godzilla@stomp.stomp.tokyo>
Re: Regular expression help <godzilla@stomp.stomp.tokyo>
Re: Regular expression help <godzilla@stomp.stomp.tokyo>
Re: Submit buttons <glodalec@yahoo.com>
This code works, but... tlynch001@my-deja.com
Re: This code works, but... (Mark-Jason Dominus)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 24 Oct 2000 13:38:14 +0900
From: "=?euc-kr?B?udrBvrq5IFwoUGFyaywgSm9uZy1Qb3JrXCk=?=" <okletsgo@NOSPAM.hitel.net (remove NOSPAM.)>
Subject: ActiveState PerlCtrl is TROJAN VIRUS?
Message-Id: <8t32lo$g1h$1@news1.kornet.net>
I get a shock.
My ALL data files was deleted by ActiveState PerlCtrl. I can't believe this fact.
I try perlctrl -f -c test.pl. And I get one dll file. And I run it on IIS5.0. (connect localhost, directory view, clicked it.)
IT DELETE ALL FILES ON MY HARDDISK! I am not beginner, have not any virus.
Here is my source. I hide my own secret codes but it is not contain any delete codes.
You can compile this code with ActiveState PerlCtrl build 206 Trial License.
My compaq notebook have no brain. I am so sad.
package JP;
unshift (@INC, ".");
use DBI;
use DBD::ODBC;
use Cwd;
use Storable;
use LWP;
use LWP::Authen::Basic;
use LWP::Authen::Digest;
use LWP::RobotUA;
use LWP::Simple;
use LWP::UserAgent;
use LWP::Protocol;
use LWP::Protocol::http;
use LWP::Parallel;
use LWP::Parallel::Protocol::http;
use LWP::Parallel::RobotUA;
use LWP::Parallel::UserAgent;
use LWP::ParallelUA;
use LWP::RobotPUA;
use URI;
use URI::http;
use URI::https;
use URI::URL;
use URI::WithBase;
use HTTP::Request;
sub Initialize {
$RobotAction;
$RobotAgentname;
$RobotProxy;
$RobotDelay;
$RobotMaximumhosts;
$RobotMaximumrequest;
$RobotTimeout;
$RobotWaitout;
$RobotRecoversize;
$RobotRecoverdate;
$ControlAction;
$ControlDebug;
$ControlRobot;
$ControlAgent;
$DatabaseDriver;
$DatabaseUsername;
$DatabasePassword;
$cwd = cwd;
$RobotTimeout = 10 if $RobotTimeout eq '';
$RobotWaitout = 10 if $RobotWaitout eq '';
$RobotMaximumhosts = 10 if $RobotMaxhosts eq '';
$RobotMaximumrequest = 10 if $RobotMaxhosts eq '';
$RobotRecoversize = 0 if $RobotRecoversize eq '';
$RobotProxy .= "/" if ( ($RobotProxy ne '') && ($RobotProxy !~ /\/$/) );
$pua = LWP::Parallel::UserAgent->new();
$pua->in_order(1);
$pua->duplicates(0);
$pua->redirect(1);
$pua->timeout($RobotTimeout);
$pua->max_hosts($RobotMaximumhosts);
$pua->max_req($RobotMaximumrequest);
$pua->agent($RobotAgentname);
$pua->from($RobotContactemail);
$pua->delay($RobotDelay) if $RobotDelay ne '';
$pua->proxy('http',$RobotProxy) if $RobotProxy ne '';
}
=pod
=begin PerlCtrl
%TypeLib = (
PackageName => 'JP',
TypeLibGUID => '{9E65543C-DB10-48FF-9A60-3163F61CF021}', # do NOT edit this line
ControlGUID => '{CCB6D057-BB8E-45BB-93F6-200225378A57}', # do NOT edit this line either
DispInterfaceIID=> '{B4062D6B-066A-426A-85C2-7422A996BACF}', # or this one
ControlName => 'AgentJP.Control',
ControlVer => 1, # increment if new object with same ProgID
# create new GUIDs as well
ProgID => 'JP',
DefaultMethod => 'Initialize',
Methods => {
'Initialize' => {
RetType => VT_I4,
TotalParams => 5,
NumOptionalParams => 2,
ParamList =>[ 'ParamName1' => VT_I4,
'ParamName2' => VT_BSTR,
'ParamName3' => VT_BOOL,
'ParamName4' => VT_I4,
'ParamName5' => VT_UI1 ]
},
}, # end of 'Methods'
Properties => {
'MyIntegerProp' => {
Type => VT_I4,
ReadOnly => 0,
},
'MyStringProp' => {
Type => VT_BSTR,
ReadOnly => 0,
},
'Color' => {
Type => VT_BSTR,
ReadOnly => 0,
},
'MyReadOnlyIntegerProp' => {
Type => VT_I4,
ReadOnly => 1,
},
}, # end of 'Properties'
); # end of %TypeLib
=end PerlCtrl
=cut
oh my god......
------------------------------
Date: Tue, 24 Oct 2000 08:40:54 +0200
From: Toralf Lund <toralf@kscanners.com>
Subject: Connecting directly to rsh daemon
Message-Id: <39F52EF6.C038CF4D@kscanners.com>
I've asked this question before, but it was buried deep down in some
thread, so I'll try again:
Does anyone have a module, routines or example code that executes a
command on a remote host and does not use system("rsh ...") or similar,
but instead connects directly to the daemon using sockets?
--
- Toralf
------------------------------
Date: Tue, 24 Oct 2000 04:20:44 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: detecting client disconnect
Message-Id: <slrn8va3gl.atb.efflandt@efflandt.xnet.com>
On Mon, 23 Oct 2000, kenny@barmeister.com <kenny@barmeister.com> wrote:
>I was wondering if there was a way to detect whether a client had lost
>their connection while executing a cgi request to a perl script. I am
>printing a download to STDOUT and when that is done I set a flag that
>says the download completed successfully. The problem is that some
>users are losing their Internet connection during this process but the
>script continues to run and updates the flag to say that they
>successfully got the file. Anyway any help with this problem would be
>greatly appreciated. Thanks........
While a Perl script will typically terminate when attempting to print to a
closed STDOUT, one problem may be server buffering. So you may not be
aware that it was terminated unless it was cutoff before the end of the
buffer size. The question is, how big is the server buffer and is it
dynamically sized based on load?
I also found that certain versions of MSIE used to request a file twice,
maybe the first time to use its own methods (instead of Content-type) to
figure out file type. I don't know if it still does that, but at the time
I was testing that, an accurate count of downloads was impossible.
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Tue, 24 Oct 2000 00:52:46 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Don't use -w in CGI?
Message-Id: <brian-ya02408000R2410000052460001@news.panix.com>
In article <8t27nu$6d9$1@orpheus.gellyfish.com>, Jonathan Stowe <gellyfish@gellyfish.com> posted:
> On Mon, 23 Oct 2000 16:52:18 GMT JL Goldstein wrote:
> > I seem to remember reading somewhere that, once one's Perl CGI script is
> > debugged, the script should not be on the Web server with the -w switch.
> > The reasoning, as I recall, was that error messages printed to the
> > browser window could give the user system information that could
> > facilitate hacking.
> There is no security issue surrounding the use of the '-w' switch - it would
> be usefull if you could remember where you had read this piecce of
> misinformation so an adequate rebuttal could be made.
error messages printed to the browser window can expose system details,
which i consider a security issue. whether or not -w is the culprit
is another matter.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Tue, 24 Oct 2000 06:39:45 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: File locking
Message-Id: <dgbavsgco7cli0b8chkeubd2q2lsfhrt2p@4ax.com>
Michael Cook wrote:
>I have read it most carefully - you have given *how* to flush. What if you
>are writing to more than 1 file with the same script? Should you flush for
>each? Or is 1 flush at the beginning of the script sufficient?
Autoflush is per filehandle. Actually, even $| is only for the currently
selected handle. If you'd want to autoflush them all, you'd have to
select them all one by one, and set $| each time.
my $stdout = select FH1;
$| = 1;
select FH2;
$| = 1;
select FH3;
$| = 1;
select $stdout;
In such a case, several lines like
$fh->autoflush;
wouldn't look as silly.
--
Bart.
------------------------------
Date: Tue, 24 Oct 2000 04:17:18 GMT
From: harris_m@my-deja.com
Subject: Re: Invalid switch msg on system call
Message-Id: <8t32gb$9nr$1@nnrp1.deja.com>
You must have set .pl ext file to call perl.exe. Check your command
line option for .pl file. You can check it by looking at file manager
or explorer "View-> Option-> file Type"
In article <8t2hu7$2qfb$1@nntp1.ba.best.com>,
Kent Scheidegger <scheideg@mars.entic.net> wrote:
> I'm running perl on a Win98 machine. Every time I make a system=20
> call, I get a message=8F"Invalid switch". This happens even with=20
> a simple call like this:
>
> system ("dir");
>
> The command works, but I get this annoying message.
>
> Apparently something in my perl setup is passing an invalid switch
> when it invokes the shell. How can I find out what it's doing wrong
> and fix it?
>
> Thanks for any info.
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 24 Oct 2000 05:18:22 GMT
From: msalerno@my-deja.com
Subject: New to Perl, Need Help !
Message-Id: <8t362q$cds$1@nnrp1.deja.com>
I am trying to write a basic script that will add some IP addresses to a
text file. It is not complete but so far I have had a few problems. I
am trying to use labeled blocks to redo a segment in the event that the
addresses match. I would also like to make sure that the IP addresses
entered are actually IP addresses, I don't need to validate the IP
addresses but I would like to make sure that the syntax is correct.
Here is the script, any help would be appreciated.
Thanks,
Matt
#/usr/bin/perl -w
ADDRESS:
print "Enter the IPOA IP Address: ";
$ipoaip = <STDIN>;
chomp ($ipoaip);
print "Enter the Ethernet IP Address: ";
$ethip = <STDIN>;
chomp ($ethip);
if ($ipoaip eq $ethip){
print "The IPOA and Ethernet Address must be different\n";
} else {
print "You entered IPOA $ipoaip\n";
print "You entered Ethernet $ethip\n";
redo ADDRESS;
}
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 24 Oct 2000 08:12:40 +0200
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.li>
Subject: Re: On being Schwartz.. (was Re: newbie cgi examples)
Message-Id: <ld8avsgqc8c36ig7larc8ria7j2eeavmv8@4ax.com>
On 23 Oct 2000 05:24:23 -0700, merlyn@stonehenge.com (Randal L. Schwartz) wrote:
> Just another guy with Schwartz in his name not related to ANY other Schwartz's,
How about Muriel Hemingway, though? You related to her? :)
Cheers,
Philip
------------------------------
Date: Tue, 24 Oct 2000 01:47:07 -0400
From: Joe Kline <jkline@one.net>
Subject: OT: Jihad definition
Message-Id: <39F5225B.7D879CE1@one.net>
"Godzilla!" wrote:
>
> Jihad Battikha wrote:
>
> > "Godzilla!" wrote:
> > > Jihad Battikha wrote:
> > > (Battikha has the same problem with no attributes)
>
> > Why are you addressing me by my last name and in the third person?
>
> It causes me concern to address you in an active
> first person voice and address you by your given
> name, which is,
>
> "Muslim Fanatic Holy War"
>
> Many people would consider this name of yours
> as a metaphor meaning "a terrorist". Muslim
> terrorists, any nationality of terrorists, are
> not high on my list of popular people. Fanatics
> are a type of people whom raise my level of concern.
Enlightened folk would defer to the larger meaning of jihad - striving
or determined effort (I've heard it defined as "the struggle").
A lucid article about the meaning of jihad is at:
http://www.ict.org.il/articles/jihad.htm
I tend to think of jihad in general to mean the struggle to come to
grips with one's faith (in Allah in this case) and to spread that
faith. While there are many references to jihad in an armed sense, the
context determines the intention/meaning.
Given that the Arab world gave us algebra, preserved/advanced
chemistry, and preserved a lot of the Greek texts, I tend to defer to
the benefits the Moors had. Of course, there are plenty in the Muslim
world that preach violence.
--
Joe Kline
It takes a lot of brains to enjoy satire, humor, and wit;
but none to be offended by them. ---The Midnight Skulker
------------------------------
Date: Tue, 24 Oct 2000 06:16:27 GMT
From: flam73@my-deja.com
Subject: Re: Perl:socket connection port 23
Message-Id: <8t39fo$f0u$1@nnrp1.deja.com>
In article <8t167j$sej$1@sshuraaa-i-1.production.compuserve.com>,
"Bruce Phipps" <bruce_phipps@my-deja.com> wrote:
> use IO::Socket
>
> to create a socket.
>
> Look at man IO::Socket, I think there are some examples included.
>
> HTH
> Bruce
>
>
on
http://www.cs.uno.edu/~golden/Teach/client
I found an example to create network client.
Changed
$this = pack($sockaddr, AF_INET, 0, $thisaddr);
into
$this = pack($sockaddr, AF_INET, 23, $thisaddr);
This was successfull.
Thanks for the info,
Patrick
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 24 Oct 2000 05:24:12 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: PerlMagick...
Message-Id: <slrn8va77o.a0g.mgjv@verbruggen.comdyn.com.au>
On Mon, 23 Oct 2000 20:08:35 +0100,
Speed Demon <speed.demon9999@virgin.net> wrote:
> Hi, I have ImageMagick and Perl Magick both installed and working on my
> server.
> Only problem is, I have no idea how to use them :)
>
> The documentation is basically crap, cant find any good stuff, anywhere.
They do their best. Up until now creating code and improving the
package has just been a higher priority than writing more
documentation.
> Basically I have a bunch of images that all need to be 72x14 pixels. Some
> are a few pixels out.
> I need to readin all the images and the crop them accordingly, if you can
> send me some sample code I'd appreciate it greatly.
Make sure you copy your images before running this. It will overwrite
all of them.
#!/usr/local/bin/perl
use strict;
use Image::Magick;
die "Need some file names" unless @ARGV;
foreach (@ARGV)
{
my $im = Image::Magick->new();
my $rc = $im->Read($_);
warn "$_: $rc", next if $rc;
$rc = $im->Crop(geometry => '32x14');
warn "$_: $rc", next if $rc;
$rc = $im->Write($_);
warn "$_: $rc" if $rc;
}
This little script is more or less equivalent to
# mogrify -crop "32x14" FILENAMES
You could read the manual pages of the mogrify and convert tools. They
give a reasonably good explanation of the options, and most command
line options to those tools have been translated to Perl functions in
some way or another.
Martien
--
Martien Verbruggen |
Interactive Media Division | +++ Out of Cheese Error +++ Reinstall
Commercial Dynamics Pty. Ltd. | Universe and Reboot +++
NSW, Australia |
------------------------------
Date: Tue, 24 Oct 2000 05:06:59 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Processing an Email (sendmail) attachment with Perl
Message-Id: <slrn8va67f.a0g.mgjv@verbruggen.comdyn.com.au>
On Mon, 23 Oct 2000 20:06:07 -0700,
Gary J. Artim <gartim@ix.netcom.com> wrote:
> Question: Can you act as an email client using Perl and
> read emails and process attached files as data? We have
Me, personally? Nope :)
> a Website where some of the clients refuse to use our
> upload page, but will email us attached, tab-delimited
> files. I'd like to get them thru Perl and auto upload them
> to my mysql database. Has anyone done this.
You should probably have a look at the many mail related modules on
CPAN. Start at search.cpan.org.
You probably might be interested in Graham Barr's MailTools to parse
the mail, MIME::Base64 and/or the MIMETools package, and if you need
to pull it from a POP server or IMAP server you may need
Mail::POP3Client, Net::POP3, Mail::IMAPClient or Net::IMAP.
Have a look around, and see what suits your needs best. You don't
really give enough information to make a more sensible recommendation.
Martien
--
Martien Verbruggen | My friend has a baby. I'm writing
Interactive Media Division | down all the noises the baby makes so
Commercial Dynamics Pty. Ltd. | later I can ask him what he meant -
NSW, Australia | Steven Wright
------------------------------
Date: Tue, 24 Oct 2000 06:06:28 GMT
From: jsfinn@my-deja.com
Subject: Regular expression help - redefinition of the problem
Message-Id: <8t38t2$eim$1@nnrp1.deja.com>
Thanks everyone, these are all great ideas, but unfortunately they
don't help, so let me clearify my problem.
A customer has given me a file to populate a "user accounts" type
table in a database, including user names and passwords. There are
restrictions on the field for the password, tho. I have a parser
that I can run the file thru to tell me if there is any bad data...
the problem is that the parser defines passable fields thru only 1
regular expression...
ie: username=^\w+$
So, I need a single regular expression that will match my criteria
a) 6-10 chars long
b) at least 1 letter
c) at least 1 digit.
After pounding my head for several days, I found a (simple, but
extremely verbose) way of doing it:
password=^(
(\d[a-zA-Z]|[a-zA-Z]\d)\w{4,8}|
\w(\d[a-zA-Z]|[a-zA-Z]\d)\w{3,7}|
\w{2}(\d[a-zA-Z]|[a-zA-Z]\d)\w{2,6}|
\w{3}(\d[a-zA-Z]|[a-zA-Z]\d)\w{1,5}|
\w{4}(\d[a-zA-Z]|[a-zA-Z]\d)\w{0,4}|
\w{5}(\d[a-zA-Z]|[a-zA-Z]\d)\w{0,3}|
\w{6}(\d[a-zA-Z]|[a-zA-Z]\d)\w{0,2}|
\w{7}(\d[a-zA-Z]|[a-zA-Z]\d)\w{0,1}|
\w{8}(\d[a-zA-Z]|[a-zA-Z]\d)\w{0}
)$
The original problem was that I was having an "AND" problem
like saying
$pass =~ /\w{6,10}/ && $pass =~/(\d[a-zA-Z]|[a-zA-Z])/
because I'm not actually writing the code.... just the regular
expression.
Anyone have a more elegant way of doing this?
Thanks for all your help
-jsf
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 23 Oct 2000 22:03:54 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Regular expression help
Message-Id: <39F5183A.8A0F4506@stomp.stomp.tokyo>
James Taylor wrote:
> Godzilla! wrote:
> > This next one has me boogered on the trinary
> > conditional operator.
> > > Locale-wise version:
> > > /(?:\w.*){6}/s && /\d/ && /[^\W_\d]/
> > trinary conditional operator (I'm am lost here)
> I think what you need to know is that within a regular
> expression (?:something) means group the something as
> a single item but do not remember it in $1, $2, etc.
Ok, I have determined how this behaves depends on
syntax. In this syntax,
test expression ? if true expression : if false expression
use of ?: is a trinary conditional operator. So for
Mr. Rosler's syntax, it is not a trinary operator.
Safari, so good.
Referencing page 68 and 69, Camel Two, I understand
those syntax ok except for ?: used in a match regex.
As Murphy's Law would have it, there is a note about
a syntax error in older Perl versions. I run 5.003
which might be a problem. No reference is made to
which earlier versions of Perl.
An example using split () is cited and indicates
no extra fields are created with use of ?: for
a split based on a multiple character split using
OR operators and word boundries. I suppose I could
experiment with this and determine what happens
based on output results. Randal's explanation is
not real clear on ?: in Camel Two.
For Mr. Rosler's regex,
/(?:\w.*){6}/s && /\d/ && /[^\W_\d]/
I still cannot make sense of what ?: is
actually doing. A split is not involved.
An ordinary mixed character string would
be input, why ?: to call for grouping
without backreferences? Seems this would
perform the same function,
/\w.* {6}/s && /\d/ && /[^\W_\d]/
Suppose my best bet is to setup a test
script and run both syntax then observe
output for each.
All of the other regular expression extensions
make perfect sense. This one has thrown me for
a core dumping loop.
Thanks for the Camel Two reference, this is
helping quite a bit. Least I know it isn't
some weird trinary thing.
Godzilla!
------------------------------
Date: 24 Oct 2000 05:50:57 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Regular expression help
Message-Id: <slrn8va8q1.5nq.sholden@pgrad.cs.usyd.edu.au>
On Mon, 23 Oct 2000 22:03:54 -0700,
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>
>For Mr. Rosler's regex,
>
>/(?:\w.*){6}/s && /\d/ && /[^\W_\d]/
>
>I still cannot make sense of what ?: is
>actually doing. A split is not involved.
>An ordinary mixed character string would
>be input, why ?: to call for grouping
>without backreferences? Seems this would
>perform the same function,
>
>/\w.* {6}/s && /\d/ && /[^\W_\d]/
>
>Suppose my best bet is to setup a test
>script and run both syntax then observe
>output for each.
That would match the space after the .* 6 times instead of matching
\w.* six times.
The ?: is purely for efficiency concerns, it saves perl from wasting time
and space on keeping track of the backreferences.
If you don't like it, then don't use it...
You'll still need the ()s of course, since (\w.*){6} is very different
from \w.*{6}.
/(?:\w.*){6}/ is the same as /(\w.*){6}/, except that in the former $1 is not
set.
--
Sam
About the only thing most people know about black holes is they are
black, and now we have stuffed that up
-- Dr Paul Francis (after reporting finding 'pink' holes)
------------------------------
Date: Tue, 24 Oct 2000 05:59:20 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Regular expression help
Message-Id: <sva99o8od7bha7@corp.supernews.com>
Jeff Zucker (jeff@vpservices.com) wrote:
: jsfinn@my-deja.com wrote:
: > At least 6 alpha-numeric characters
: > there must be at least 1 digit
: > there must be at least 1 letter
:
: /\d/ && /\D/ && /^[a-zA-Z0-9]{6,}$/
"/\D/" isn't equivalent to "letter".
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Quidquid latine dictum sit, altum viditur."
|
------------------------------
Date: Tue, 24 Oct 2000 06:02:55 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Regular expression help
Message-Id: <sva9gfcknu3n3d@corp.supernews.com>
Larry Rosler (lr@hpl.hp.com) wrote:
: Locale-dumb version (ASCII letters only):
:
: tr/A-Za-z_0-9// >= 6 && tr/0-9// && tr/A-Za-z//
That will pass anything with at least six alphanumerics and one each of
alpha and numeric; the excess characters beyond six could be anything.
For example 'abc&&&&123' would evaluate as true against the test above.
: Locale-wise version:
:
: /(?:\w.*){6}/s && /\d/ && /[^\W_\d]/
Same problem.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Quidquid latine dictum sit, altum viditur."
|
------------------------------
Date: Tue, 24 Oct 2000 06:12:58 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Regular expression help
Message-Id: <svaa3atd8qo9c6@corp.supernews.com>
Godzilla! (godzilla@stomp.stomp.tokyo) wrote:
: This next one has me boogered on the trinary
: conditional operator.
:
: > /(?:\w.*){6}/s && /\d/ && /[^\W_\d]/
^^ Right here, I presume you mean?
While this looks like a compressed a?b:c trinary conditional expression,
it's not. (Oddly, I'd never noticed the similarity.) This is a regex
syntax for 'non-capturing parentheses'. By default, regex parentheses do
two jobs:
1. Group subpatterns for treatment as a unit (in the example above, we
want 6 of the combination \w-plus-.*)
2. Capture the text matched by a subpattern for use in \N or $N constructs
later on in the regex or substitution portion of a s/// repectively.
These two functions would not be connected were it not for the needs of
notational convenience and the tragic shortage of bracket character types
in ASCII.
Since most of the time only function 1 (grouping) is needed, and it is
convenient both to document that and to avoid the overhead of needless
capturing, one of the Perl 5 versions introduced a syntax for non-
capturing parentheses; that is, a way to group but not capture. That
syntax is (?: ... ).
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Quidquid latine dictum sit, altum viditur."
|
------------------------------
Date: Mon, 23 Oct 2000 23:15:58 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Regular expression help
Message-Id: <39F5291E.1D7FB7D2@stomp.stomp.tokyo>
Sam Holden wrote:
> Godzilla! wrote:
(snipped)
> If you don't like it, then don't use it...
I have made no comment regarding my like or
dislike of this syntax involved. I have asked
for some help understanding what it does.
Godzilla!
------------------------------
Date: Mon, 23 Oct 2000 23:28:52 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Regular expression help
Message-Id: <39F52C24.159C91FB@stomp.stomp.tokyo>
Sam Holden wrote:
> Godzilla! wrote:
(snippage)
> >For Mr. Rosler's regex,
> >/(?:\w.*){6}/s && /\d/ && /[^\W_\d]/
> > I still cannot make sense of what ?: is
> > actually doing.
> >/\w.* {6}/s && /\d/ && /[^\W_\d]/
> >Suppose my best bet is to setup a test
> >script and run both syntax then observe
> >output for each.
> The ?: is purely for efficiency concerns, it saves perl from wasting time
> and space on keeping track of the backreferences.
> You'll still need the ()s of course, since (\w.*){6} is very different
> from \w.*{6}.
> /(?:\w.*){6}/ is the same as /(\w.*){6}/, except that in the former $1 is not
> set.
If I am understanding this correctly, parentheses for this
syntax are needed to use the s switch. Use of ?: is to prevent
perl core from treating those parentheses as 'memory' parentheses.
This makes sense now, if I understand this correctly.
I will work on this. I understand ?: now, what it does and all.
Currently, I am a bit confused on parentheses and the s switch.
Perhaps I am thinking too hard on this and cannot clear my
mind's eye vision to see what all is happening.
Thanks for your help.
Godzilla!
------------------------------
Date: Mon, 23 Oct 2000 23:46:52 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Regular expression help
Message-Id: <39F5305C.53EE16E8@stomp.stomp.tokyo>
Craig Berry wrote:
> Godzilla! wrote:
> : This next one has me boogered on the trinary
> : conditional operator.
> : > /(?:\w.*){6}/s && /\d/ && /[^\W_\d]/
> ^^ Right here, I presume you mean?
> While this looks like a compressed a?b:c trinary conditional expression,
> it's not. (Oddly, I'd never noticed the similarity.)
Well leave it to me to see something which ain't there!
I honestly thought Mr. Rosler was pulling some slick
trick with trinary. I figured there must be default
values for a trinary if you don't include expressions,
much like $_ has and is an invisible default.
> This is a regex syntax for 'non-capturing parentheses'.
> By default, regex parentheses do two jobs:
> 1. Group subpatterns for treatment as a unit (in the example above, we
> want 6 of the combination \w-plus-.*)
OH!!! Ok, now I get it! Those parentheses are instructing
perl core to find 'six' of something with at least one
alpha character included, regardless of string length.
* light bulb goes on over her head *
Now all the pieces are beginning to fit,
"Find a pattern of six with a minimum of one alpha
character and don't memorize this pattern then go
ahead and evaluate my logical and expressions."
I think I have it now! There is no real connection
between those parentheses and the s switch. Mr. Rosler
used the s switch to ignore \n characters to span more
than one line for a match. His syntax is marching right
down the line, narrowing his constraints as he goes
along; a series of "logical and" for efficiency each
with tighter restrictions.
Whew, this one really threw me for a doozy.
> 2. Capture the text matched by a subpattern for use in \N or $N constructs
> later on in the regex or substitution portion of a s/// repectively.
Don't talk about stuff I have never read about or heard about.
\N ???? I will research this.
> These two functions would not be connected were it not for the needs of
> notational convenience and the tragic shortage of bracket character types
> in ASCII.
Yes, Perl does need more symbology. There are two
other matching 'bracket' like symbols I know of,
« » and ‹ › <-- those are not html brackets.
> Since most of the time only function 1 (grouping) is needed, and it is
> convenient both to document that and to avoid the overhead of needless
> capturing, one of the Perl 5 versions introduced a syntax for non-
> capturing parentheses; that is, a way to group but not capture. That
> syntax is (?: ... ).
Got it! I will test my Perl version, 5.003, to discover if
this works.
Thank you, great help!
Kira
------------------------------
Date: Tue, 24 Oct 2000 06:28:46 +0200
From: marvin <glodalec@yahoo.com>
Subject: Re: Submit buttons
Message-Id: <MPG.145f2e6dc4ce2aea989684@news.siol.net>
In article <%c5J5.278$h32.225140@typhoon.southeast.rr.com>,
jlinch@mediaone.net says...
> Is it possible to have multiple Submit buttons on a form? What I want to do
> is set up a form to add, edit, or delete a database record. My thought is to
> have a Submit button for each of these actions. Obviously, I would want to
> be able to tell, from the Perl script, which button was pressed so that I
> could handle it appropriately. Any help on this would be appreciated.
>
> Jerry Linch
> jlinch@mediaone.net
>
>
>
>
One way to do it is
<INPUT TYPE=image SRC=/usr/mypic/pica.gif NAME=add>
<INPUT TYPE=image SRC=/usr/mypic/pice.gif NAME=edit>
<INPUT TYPE=image SRC=/usr/mypic/picd.gif NAME=delete>
Paramaterers are passed to the cgi as
add.x=15&add.y=17 if add is clicked and so on
so
AddRecord() if param('add.x') ;
EditRecord() if param('edit.x') ;
DeleteRecord() if param('delete.x') ;
would probably work
------------------------------
Date: Tue, 24 Oct 2000 04:09:48 GMT
From: tlynch001@my-deja.com
Subject: This code works, but...
Message-Id: <8t3229$9ah$1@nnrp1.deja.com>
This code works, but I was hoping someone would show me a better
solution.
This is code for a simplified FTP client using UDP. The server is
written in 'C' and is expecting a two byte unsigned short integer
checksum. I didn't know how to convert my checksum into two bytes. My
solution was to unpack it into 16 bits, divide these 16 bits into two 8
bit chars, and then concatinate them. Is there a better way?
Thanks,
Tom
tlynch001@earthlink.net
#The code in question...
$TER = chr(56); #TERminate
$FIL = chr(16); #FILe name packet
$ACK = chr(24); #ACKnowledgement packet
# Put together the FIL packet...
$Length = chr(length($filename)); #that chr() makes it a char
$FilePacket = $FIL.$Length.$filename; # no checksum yet...
# The next part is a little weird.
$CheckSum = unpack("%16C*", $FilePacket);
# Concantinate using '.'
$FilePacket = $FIL.$Length.$filename.chr($CheckSum >> 8).chr($CheckSum);
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 24 Oct 2000 05:45:58 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: This code works, but...
Message-Id: <39f52216.1172$2a5@news.op.net>
In article <8t3229$9ah$1@nnrp1.deja.com>, <tlynch001@my-deja.com> wrote:
>I didn't know how to convert my checksum into two bytes. My
>solution was to unpack it into 16 bits, divide these 16 bits into two 8
>bit chars, and then concatinate them. Is there a better way?
$bytes = pack("n", $checksum);
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 4707
**************************************