[24741] in Perl-Users-Digest
Perl-Users Digest, Issue: 6896 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 21 11:06:14 2004
Date: Sat, 21 Aug 2004 08:05:06 -0700 (PDT)
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, 21 Aug 2004 Volume: 10 Number: 6896
Today's topics:
A good read from Larry Wall <noemail@#$&&!.net>
Re: Any YahooPop/fetchyahoo Like For NNTP on Google? <1122@1122noexiste.net>
bytes and characters - how to decode? (Panchal V)
Re: bytes and characters - how to decode? <tassilo.von.parseval@rwth-aachen.de>
Re: Can I modify scalars contained in the array ref ret <bmb@ginger.libs.uga.edu>
Re: Database vs Text for text search <invalid-email@rochester.rr.com>
Re: Earthquake forecasting program Aug. 16, 2004 <edgrsprj@ix.netcom.com>
Re: Earthquake forecasting program Aug. 16, 2004 <tadmc@augustmail.com>
Re: Javascript, ODBC, and Oracle functions returning cu <jnorth@yourpantsbigpond.net.au>
Re: no re 'eval' not secure enough <nobull@mail.com>
Re: Processing Qmail Smtp Session Log (BadApple)
Re: split inconsistency- why? (David Combs)
Re: what's the best environment to exercise Perl? <end@dream.life>
Re: what's the best environment to exercise Perl? <postmaster@castleamber.com>
Re: Why '' Is Matched First Time, Not Second Time <noreply@gunnar.cc>
Re: Why '' Is Matched First Time, Not Second Time <ebohlman@omsdev.com>
Re: Why '' Is Matched First Time, Not Second Time <SaveWorldFromAids@alexa.com>
Re: Why '' Is Matched First Time, Not Second Time <sholden@flexal.cs.usyd.edu.au>
Re: Why '' Is Matched First Time, Not Second Time greymaus@yahoo.com
Re: Why '' Is Matched First Time, Not Second Time <tadmc@augustmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 20 Aug 2004 20:46:25 -0500
From: Fred <noemail@#$&&!.net>
Subject: A good read from Larry Wall
Message-Id: <pan.2004.08.21.01.46.24.898439@#$&&!.net>
The State of the Onion #8: Larry Wall's "State of the Onion" speeches are
always really entertaining: they're nominally about the current state of
Perl, but really they're about all kinds of things. The latest one was
mostly about his recent health problems, but also about community,
cognition, and design. This time, instead of slides, he ran screen savers
and related the behavior of each to what he was talking about.
http://www.perl.com/pub/a/2004/08/18/onion.html
Author disclaimers:
1. I found this link here:
http://jwz.livejournal.com/
2. I never knew about "The State of the Onion" till today. 3. Love perl
more all the time. What a sharp sword to practice at expertise with. I'm
not sure it can't do anything. (!!) (;))
------------------------------
Date: Sat, 21 Aug 2004 14:06:25 +0200
From: Brad Blanchard <1122@1122noexiste.net>
Subject: Re: Any YahooPop/fetchyahoo Like For NNTP on Google?
Message-Id: <VA.000028f4.004d70cb@braser.com>
Bill Clark wrote:
> Careful with this one as they use their own message id system which can
> screw up threading in some news readers...
As I can attest to. I signed up for a free account last January and everything
worked well until the beginning of July when they changed servers. From that
point on my news client kept on downloading old messages which I had deleted.
Their support just kept telling me that everything was working perfectly and
there was no problem. I finally signed up for a basic account at newsguy.com.
The $40 per year is worth it to avoid the problems that TeraNews has, and the
news feeds are much better.
--
Brad Blanchard
Website: http//www.braser.com
email accepted from the website
------------------------------
Date: 21 Aug 2004 01:19:15 -0700
From: vks_vikas@rediffmail.com (Panchal V)
Subject: bytes and characters - how to decode?
Message-Id: <13fbeb79.0408210019.2977df44@posting.google.com>
I have to process a packet, it looks like this :
$str = "\0\0\0\2\0\0\0\1\2\x41\x42";
version -> 2 (first 4 octects)
type -> 1 (next 4 octects)
length -> 1 (next 1 octect)
data -> 'AB' (next 2 octect)
how do i decode this packet??? i want first 4 bytes to be treated as
an Unsigned Integer i.e. version is 2 here in this case...
I tried
$str =~ m/(.{4})(.{4})(.)/;
$version = pack "I", $1;
but doesn't help... HOW CAN I extract fields values???
Thnx
-Neo
------------------------------
Date: Sat, 21 Aug 2004 10:34:37 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: bytes and characters - how to decode?
Message-Id: <2oofovFd4a59U1@uni-berlin.de>
Also sprach Panchal V:
> I have to process a packet, it looks like this :
> $str = "\0\0\0\2\0\0\0\1\2\x41\x42";
>
> version -> 2 (first 4 octects)
> type -> 1 (next 4 octects)
> length -> 1 (next 1 octect)
> data -> 'AB' (next 2 octect)
>
> how do i decode this packet??? i want first 4 bytes to be treated as
> an Unsigned Integer i.e. version is 2 here in this case...
>
> I tried
> $str =~ m/(.{4})(.{4})(.)/;
> $version = pack "I", $1;
>
> but doesn't help... HOW CAN I extract fields values???
There is no need for the pattern match when you use unpack() properly.
It can return a list of values so the unpacking can be done in one go.
Assuming the above record is two unsigned integers, followed by a length
indicator being an unsigned char and finally that many characters, you'd
do it that way:
my ($ver, $type, $data) = unpack "IIC/a", $str;
Note that the 'I' template specifies integers in the native byteorder
and native width of your machine. Since "\0\0\0\2" only represents the
value 2 on big-endian machines, it is not portable to machines with a
different byteorder. Therefore you better use 'N':
my ($ver, $type, $data) = unpack "NNC/a", $str;
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Fri, 20 Aug 2004 21:25:42 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Can I modify scalars contained in the array ref returned by DBI
Message-Id: <Pine.A41.4.58.0408202123420.50500@ginger.libs.uga.edu>
On Fri, 20 Aug 2004, Aaron Anodide wrote:
> John Bokma <postmaster@castleamber.com> wrote in message news:<Xns954AEF91080A8castleamber@130.133.1.4>...
> >
> > Also the > doesn't need to be escaped in many cases.
> > <something> a > b </something> is valid.
>
> That's interesting, I didn't know it. I wonder if it's worth the
> effort to analyze the context of the >'s though...
>
http://www.w3.org/TR/REC-xml/#syntax
Regards,
Brad
------------------------------
Date: Sat, 21 Aug 2004 01:44:31 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Database vs Text for text search
Message-Id: <4126A8FE.1030904@rochester.rr.com>
http://links.i6networks.com wrote:
...
> I have trouble to build the data structure, as I don't know how to store
> them in a text file. I am think doing =~ m//i search in perl, but also
> consider to run a system call of grep, which seems easier and simpler.
The "trouble to build the data structure, as I don't know how to store
them in a text file" would point to using a real database, even if the
quantity of data doesn't.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Sat, 21 Aug 2004 07:44:48 GMT
From: "edgrsprj" <edgrsprj@ix.netcom.com>
Subject: Re: Earthquake forecasting program Aug. 16, 2004
Message-Id: <Q3DVc.5744$2L3.2025@newsread3.news.atl.earthlink.net>
"Randal L. Schwartz" <merlyn@stonehenge.com> wrote in message
news:86657divla.fsf@blue.stonehenge.com...
> *** post for FREE via your newsreader at post.newsfeed.com ***
>
> So, if you want to be heard, be a member of the tribe. Do it the
> tribal way. Stop putting extra date headers there. That's no
> guarantee that you'll get a bigger audience, but it's certainly better
> than guaranteeing that you'll get a smaller audience if you fail to
> comply.
>
It has been a while since I posted to this Newsgroup. But as I recall, for
posts which are exclusively for this one I usually don't add any extra
heading information. A few might have slipped through this time because I
am working on multiple projects and am posting to several Newsgroups.
I am going to state the following once more. The Perl language earthquake
forecasting program I have developed is in my opinion working. And I
believe that it could be providing governments around the world with vitally
important information regarding the approach of these natural disasters
which can claim tens of thousands of lives in minutes and produce hundreds
of billions of dollars worth of damage and economic loss.
We have an integrated global economy these days. And if a country which
produces some product which is important to the rest of the world has a
major economic disruption because of an earthquake then that could have
global consequences. It could even affect some or perhaps many of the
people posting notes to this Newsgroup.
Since the main computer program involved with this technology is a Perl
program questions regarding that computer language are important. Here are
some of the decisions that need to be made or things that need to be worked
on. And unfortunately, I do not presently have any time free to address
these issues. They are scheduled for future work.
*** Is Perl the best language to use for this application?
*** How do you plot X/Y data etc. using Perl?
*** How do you generate standalone compiled Perl programs?
I know that there is information available regarding the X/Y plots and
compiled programs. But as I said, I don't have any time to work on that
right now. At the moment another computer programmer and I have even
developed a program for generating certain types of solar and lunar data.
It needs to be translated into Perl. And neither of us has time to do that
either.
------------------------------
Date: Sat, 21 Aug 2004 08:25:21 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Earthquake forecasting program Aug. 16, 2004
Message-Id: <slrncieja1.48o.tadmc@magna.augustmail.com>
edgrsprj <edgrsprj@ix.netcom.com> wrote:
> I am going to state the following once more.
WTF for?
Did you think we didn't hear you the first several times?
Repeating it over and over does not make it more viable you know.
Please go somewhere else. Thank you.
> *** Is Perl the best language to use for this application?
No.
Python would be much much better for your task.
> I know that there is information available regarding the X/Y plots and
> compiled programs. But as I said, I don't have any time to work on that
> right now.
Then it will not get done, as you seem to be an Army Of One.
> It needs to be translated into Perl.
Translate it into Python instead.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 21 Aug 2004 13:40:03 GMT
From: Jeff North <jnorth@yourpantsbigpond.net.au>
Subject: Re: Javascript, ODBC, and Oracle functions returning cursors
Message-Id: <uljei09io64s3911ivlu18f9uu5g1cok9f@4ax.com>
On 20 Aug 2004 16:32:37 -0700, in comp.lang.javascript
dba_222@yahoo.com (Roger Redford) wrote:
>| Dear Experts,
>|
>| I'm attempting to marry a system to an Oracle 817 datbase.
>| Oracle is my specialty, the back end mainly, so I don't
>| know much about java or javascript.
>|
>| The system uses javascript to make ODBC calls to the db.
>|
>| The particular system I'm working with, will not work
>| with an Oracle stored procedure I'm told. However, it
>| will work with a stored function.
>|
>| I made a simple function in Oracle to return a single
>| integer. It works in sqlplus, but not via javascript.
[snip 2 end]
Javascrit comes in 2 flavours: client-side (that appears within the
webpage). This can only manipulate items on the webpage. It can not
open files or databases.
Server-side: also known as JScript. This allows you to do all the file
/ database manipulation stuff. Check with your web people as to what
web server they are running. If IIS then ASP/JScript, ASP/VBScript or
PHP will do. If any other server then check what server-side language
they support.
Sample listed below:
-----------------------------------------------
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/ELVASS.asp" -->
<%
//--- get data from the webpage form
var tpid = Request.QueryString("tpid");
var qid = Request.QueryString("qid");
if( isNaN(tpid) || isNaN(qid) ) Response.Redirect("../menu.asp");
//--- global variables
var fname="", fExt="", TPName="", QName="", Ver="", AppDt="",
mainID=0;
var fso, f2;
var src="", dst = "", wrd="";
function WriteFormData( mainid, cid, type, fname )
{
//--- use this syntax for insert, update and delete queries
var w = Server.CreateObject('ADODB.Command');
w.ActiveConnection = MM_ELVASS_STRING;
w.CommandText = "INSERT INTO forms (fk_mainID, fk_cid,
type,filename) Values (" + mainid + "," + cid + ",\"" + type + "\",\""
+ fname + "\")";
w.Execute();
w.ActiveConnection.Close();
}
//--- get general information
//--- use this syntax for select queries
var db = Server.CreateObject("ADODB.Recordset");
db.ActiveConnection = MM_ELVASS_STRING;
db.Source = "SELECT main.id form main WHERE fk_TrainingPackage=" +
tpid + " AND fkQualID=" + qid;
db.CursorType = 0;
db.CursorLocation = 2;
db.LockType = 1;
db.Open();
while( !db.EOF )
{
//--- do something
db.moveNext();
}
db.Close();
%>
---------------------------------------------------------------
jnorth@yourpantsbigpond.net.au : Remove your pants to reply
---------------------------------------------------------------
------------------------------
Date: Sat, 21 Aug 2004 09:41:09 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: no re 'eval' not secure enough
Message-Id: <cg71r7$geu$1@slavica.ukpost.com>
In my prevous follow-up I made somewhat woolly arguments about threat
analysis. But here's a much simpler argument...
Batthew Braid wrote:
> no re 'eval';
> chomp(my $re = <STDIN>);
> {
> use re 'eval';
> $re = qr/$re/;
> }
OK stop there, that code in itself allows the user to execute arbitrary
code using (?{BEGIN{...}}). Any further discussion of what happens to
$re subsequently is therefore moot.
------------------------------
Date: 20 Aug 2004 23:01:08 -0700
From: badapple_deltree@yahoo.co.in (BadApple)
Subject: Re: Processing Qmail Smtp Session Log
Message-Id: <dda5aa58.0408202201.3fcfdbe5@posting.google.com>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<2omhtgFcf8ohU1@uni-berlin.de>...
> Gunnar Hjalmarsson wrote:
> >
> > my %hash;
> > while (<FLE>) {
> > chomp;
> > if ( /qmail-smtpd\s+(\d+).+Authenticated user:(.+)/ ) {
> > $hash{$1} = $2;
> > }
> > if ( /qmail-smtpd\s+(\d+).+queued.+size\s+(\d+)/ ) {
> > if ( $hash{$1} ) {
> > print "Pid: $1 User: $hash{$1}\n",
> > "Pid: $1 Bytes: $2\n";
> > delete $hash{$1};
> > }
> > }
> > }
>
> If the first regex matches, there is no reason to test the second
> regex, so this makes more sense:
>
> my %hash;
> while (<FLE>) {
> chomp;
> if ( /qmail-smtpd\s+(\d+).+Authenticated user:(.+)/ ) {
> $hash{$1} = $2;
> } elsif ( /qmail-smtpd\s+(\d+).+queued.+size\s+(\d+)/ ) {
> if ( $hash{$1} ) {
> print "Pid: $1 User: $hash{$1}\n",
> "Pid: $1 Bytes: $2\n";
> delete $hash{$1};
> }
> }
> }
Many Many Many Many ...... Thanx
Regards
BadApple
------------------------------
Date: Sat, 21 Aug 2004 03:42:38 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: split inconsistency- why?
Message-Id: <cg6gbe$3gd$1@reader1.panix.com>
Ilya -- thanks so much for your reply!
In article <cg5q8a$1ah3$1@agate.berkeley.edu>,
Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
SNIP
>
>I think the problematic areas are split on a REx which can match an
>empty substring, and split of an empty string. One example I remember
>is
>
> perl -wle "for (0..5) {@x=split /./, q(a) x $_, -1; print scalar @x}"
> 0
> 2
> 3
> 4
> 5
> 6
>
>> (3) If this split is *that* weird and unpredictable,
>> how much work would it be for someone (good like you)
>> to implement a splitSmall with perhaps fewer features,
>> but at least do those things robustly, "as advertised"?
>
>As I said, this was already (mostly?) done in my
>
> use strict 'split';
>
>patch. But if it is not easly transferable to the current code base,
OOPS -- with the above line sitting there, I'm
not so sure that really understand the situation:
Ilya -- are you saying that you made all these fixes
to a pre-5.6 version -- and that those fixes *did not*
make their way into (then) code base, and thus
had no chance to be kept there (obviously)
in subsequent versions?
Or what?
>keep in mind that nowadays I will need external funding to seriously
>work on Perl. (I wish I had one...)
>
...
>
>Hope this helps,
>Ilya
Yes, it does, but also brought out that new question (above).
Thanks!
David
------------------------------
Date: Sat, 21 Aug 2004 12:18:59 +0800
From: Alont <end@dream.life>
Subject: Re: what's the best environment to exercise Perl?
Message-Id: <412bccad.255031671@130.133.1.4>
John Bokma <postmaster@castleamber.com>Wrote at 20 Aug 2004 23:35:44
GMT:
>Villy Kruse <vek@station02.ohout.pharmapartners.nl> wrote in
>news:slrncibjkq.q2.vek@station02.ohout.pharmapartners.nl:
>
>> Which might result in a full quote, which isn't always appropriate
>> either. The old rule was: at most half of the total post may be quoted
>> material, and some news program did enforce that.
>
>With 60% my client gives a warning. Sometimes it's not a problem, but with
>a posting consisting of 500 lines, quoting 50% (or 100%) when you just say
>aol, is a bit of a waste :-(
>
>> If the full quote
>> is only half a page that wouldn't be a problem; several pages of quote
>> before a few line of new contribution isn't friendly to the reader.
>
>Agreed. With very long postings or emails I always reread and try to remove
>every line that can be missed, and my replies still be understood. Most of
>the time I am able to keep the quote to two or three lines.
there have a news reader could automatically delete ">>"started line
and replace empty line as two line?(splitting between two sentence)
--
Your fault as a Government is My failure as a citizen
------------------------------
Date: 21 Aug 2004 05:51:03 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: what's the best environment to exercise Perl?
Message-Id: <Xns954C8A73E604castleamber@130.133.1.4>
Alont <end@dream.life> wrote in news:412bccad.255031671@130.133.1.4:
> there have a news reader could automatically delete ">>"started line
Why? If you remove everything of the post you reply to it is similar to top
posting. If you use xnews, you can let it *keep* what you select.
> and replace empty line as two line?(splitting between two sentence)
Don't understand what you mean.
http://xnews.newsguy.com/ for Xnews. It's gui is weird here and there. Make
sure you read the manual. It has quite some nice features.
--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Sat, 21 Aug 2004 03:09:04 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Why '' Is Matched First Time, Not Second Time
Message-Id: <2onm3mFd1j68U1@uni-berlin.de>
http://links.i6networks.com wrote:
> Empty String '' is matched the first time but not the second time.
> Why?
When you noticed that the m// operator does not behave as you had
expected, you did apparently not check the description of the m//
operator in "perldoc perlop". Why?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 21 Aug 2004 01:23:08 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: Why '' Is Matched First Time, Not Second Time
Message-Id: <Xns954BD03767F88ebohlmanomsdevcom@130.133.1.4>
"http://links.i6networks.com" <SaveWorldFromAids@alexa.com> wrote in
news:YLwVc.1833114$Ar.1019409@twister01.bloor.is.net.cable.rogers.com:
> ##################Perl File
> my @line=(); my $foundcat=0;
> my $keyword1=''; my $keywordcat='';
> open ($INPUT, 'ostkall.txt') || die "can't open $file: $!";
> while (<$INPUT>) {
> chomp;
> if (!($_=~ m/.+\|.+\|.+/)) {
> if
> ($_=~ m/$keywordcat/i)
> {
> $foundcat=1;
> print "FOUND $_\n";
>
> } else {$foundcat=0;}
> } #end of if (!($_=~ m/.+\|.+\|.+/)
>
> }
> close($INPUT) ;
>
> #####################The output is
> FOUND Computers & Printers|Monitors
>
> But it should be
> FOUND Computers & Printers|Monitors
> FOUND Computers & Printers|Priners
>
>
> #################the data in ostkall.txt is
> Computers & Printers|Monitors
> | | | | |
> Computers & Printers|Printers
> | | | | |
>
> ############# Question
> Empty String '' is matched the first time but not the second time. Why?
I must admit I played around with your code for about 15 minutes, got
rather puzzled, and then got this nagging feeling "there must be something
special about null-string matches." So I did what every good Perl
programmer does when they get such a feeling and read the section on the
match operator in perlop. Sure enough, there it was:
"If the PATTERN evaluates to the empty string, the last successfully
matched regular expression is used instead. In this case, only the g and c
flags on the empty pattern is honoured - the other flags are taken from the
original pattern. If no match has previously succeeded, this will
(silently) act instead as a genuine empty pattern (which will always
match)."
When you read the very first line, no regexp has yet successfully matched,
so /$keywordcat/ matches the empty string. When you read the next line,
/.+\|.+\|.+/ successfully matches, so when you go on to read the third
line, /$keywordcat/ is now being treated as /.+\|.+\|.+/, which of course
doesn't match there.
BTW, another thing good Perl programmers do is put 'use warnings;' and 'use
strict' at the top of their programs. If you did that, you'd see that your
error message for the open was using a variable that gallopped in from
nowhere.
------------------------------
Date: Sat, 21 Aug 2004 04:22:56 GMT
From: "http://links.i6networks.com" <SaveWorldFromAids@alexa.com>
Subject: Re: Why '' Is Matched First Time, Not Second Time
Message-Id: <A6AVc.1835908$Ar.75471@twister01.bloor.is.net.cable.rogers.com>
"Eric Bohlman" <ebohlman@omsdev.com> 写入邮件
news:Xns954BD03767F88ebohlmanomsdevcom@130.133.1.4...
> "http://links.i6networks.com" <SaveWorldFromAids@alexa.com> wrote in
> news:YLwVc.1833114$Ar.1019409@twister01.bloor.is.net.cable.rogers.com:
>
> > ##################Perl File
> > my @line=(); my $foundcat=0;
> > my $keyword1=''; my $keywordcat='';
> > open ($INPUT, 'ostkall.txt') || die "can't open $file: $!";
> > while (<$INPUT>) {
> > chomp;
> > if (!($_=~ m/.+\|.+\|.+/)) {
> > if
> > ($_=~ m/$keywordcat/i)
> > {
> > $foundcat=1;
> > print "FOUND $_\n";
> >
> > } else {$foundcat=0;}
> > } #end of if (!($_=~ m/.+\|.+\|.+/)
> >
> > }
> > close($INPUT) ;
> >
> > #####################The output is
> > FOUND Computers & Printers|Monitors
> >
> > But it should be
> > FOUND Computers & Printers|Monitors
> > FOUND Computers & Printers|Priners
> >
> >
> > #################the data in ostkall.txt is
> > Computers & Printers|Monitors
> > | | | | |
> > Computers & Printers|Printers
> > | | | | |
> >
> > ############# Question
> > Empty String '' is matched the first time but not the second time. Why?
>
> I must admit I played around with your code for about 15 minutes, got
> rather puzzled, and then got this nagging feeling "there must be something
> special about null-string matches." So I did what every good Perl
> programmer does when they get such a feeling and read the section on the
> match operator in perlop. Sure enough, there it was:
>
> "If the PATTERN evaluates to the empty string, the last successfully
> matched regular expression is used instead. In this case, only the g and c
> flags on the empty pattern is honoured - the other flags are taken from
the
> original pattern. If no match has previously succeeded, this will
> (silently) act instead as a genuine empty pattern (which will always
> match)."
>
> When you read the very first line, no regexp has yet successfully matched,
> so /$keywordcat/ matches the empty string. When you read the next line,
> /.+\|.+\|.+/ successfully matches, so when you go on to read the third
> line, /$keywordcat/ is now being treated as /.+\|.+\|.+/, which of course
> doesn't match there.
I still don't understand. Why perl will do that weired, none normal thing.
Thanks alot. I was right not to waste more time on my own and came here to
ask. Saved my time for a game and a meal.
------------------------------
Date: 21 Aug 2004 07:09:08 GMT
From: Sam Holden <sholden@flexal.cs.usyd.edu.au>
Subject: Re: Why '' Is Matched First Time, Not Second Time
Message-Id: <slrncidt8k.2tp.sholden@flexal.cs.usyd.edu.au>
On Sat, 21 Aug 2004 04:22:56 GMT,
http://links.i6networks.com <SaveWorldFromAids@alexa.com> wrote:
>
> "Eric Bohlman" <ebohlman@omsdev.com> 写入邮件
> news:Xns954BD03767F88ebohlmanomsdevcom@130.133.1.4...
>>
>> I must admit I played around with your code for about 15 minutes, got
>> rather puzzled, and then got this nagging feeling "there must be something
>> special about null-string matches." So I did what every good Perl
>> programmer does when they get such a feeling and read the section on the
>> match operator in perlop. Sure enough, there it was:
>>
[snip perl doc quote]
>
> I still don't understand. Why perl will do that weired, none normal thing.
> Thanks alot. I was right not to waste more time on my own and came here to
> ask. Saved my time for a game and a meal.
So wasting everyone elses time, so that someone can read the standard
documentation to you is worth saving yourself the time of reading the
relevant docs?
*plonk*
--
Sam Holden
------------------------------
Date: 21 Aug 2004 13:27:27 GMT
From: greymaus@yahoo.com
Subject: Re: Why '' Is Matched First Time, Not Second Time
Message-Id: <slrncidjh1.2fa.greymaus@darkstar.ie>
On Sat, 21 Aug 2004 03:09:04 +0200, Gunnar Hjalmarsson wrote:
> http://links.i6networks.com wrote:
>> Empty String '' is matched the first time but not the second time.
>> Why?
>
> When you noticed that the m// operator does not behave as you had
> expected, you did apparently not check the description of the m//
> operator in "perldoc perlop". Why?
>
AFAIK, it does the same in `vi'?
--
greymaus
Al Firan RumaiDin
97.025% of statistics are wrong
------------------------------
Date: Sat, 21 Aug 2004 08:20:33 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Why '' Is Matched First Time, Not Second Time
Message-Id: <slrnciej11.48o.tadmc@magna.augustmail.com>
http://links.i6networks.com <SaveWorldFromAids@alexa.com> wrote:
> "Eric Bohlman" <ebohlman@omsdev.com> 写入邮件
> news:Xns954BD03767F88ebohlmanomsdevcom@130.133.1.4...
>> So I did what every good Perl
>> programmer does when they get such a feeling and read the section on the
>> match operator in perlop. Sure enough, there it was:
> I was right not to waste more time on my own
No you weren't.
You were wrong to not read the documentation for the operator
that you were using.
We are not here to read the docs to you!
> Saved my time
At the expense of other people.
Not being a very good "community member" there you know.
So long.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 6896
***************************************