[24080] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6274 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 18 14:05:50 2004

Date: Thu, 18 Mar 2004 11:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 18 Mar 2004     Volume: 10 Number: 6274

Today's topics:
    Re: a doubt in unicode sub-properties <nobull@mail.com>
        Amulating post back to a .net server (benny s.)
    Re: Amulating post back to a .net server <roel-perl@st2x.net>
    Re: capitalizing each word in an array <nobull@mail.com>
        converting an evaluated expression to a literal (Ashkan)
    Re: converting an evaluated expression to a literal <ittyspam@yahoo.com>
    Re: CPAN module install error <jwillmore@remove.adelphia.net>
    Re: Empty hash key produces funky results <bmb@ginger.libs.uga.edu>
    Re: How do you reference web form elements? <remorse@partners.org>
    Re: HOW TO PARSE A VAST FILE! <xxala_qumsiehxx@xxyahooxx.com>
    Re: HOW TO PARSE A VAST FILE! <peter@semantico.com>
    Re: HOW TO PARSE A VAST FILE! <luke@program.com.tw>
    Re: HOW TO PARSE A VAST FILE! <luke@program.com.tw>
    Re: HOW TO PARSE A VAST FILE! <xx087@freenet.carleton.ca>
    Re: HOW TO PARSE A VAST FILE! <xxala_qumsiehxx@xxyahooxx.com>
    Re: HOW TO PARSE A VAST FILE! <kirk@strauser.com>
    Re: Multiple compares -- TMTOWTDI (Steve The Geek)
    Re: Multiple compares -- TMTOWTDI <ittyspam@yahoo.com>
    Re: Perl script to transfer file via https <jwillmore@remove.adelphia.net>
        perl Threads <mail@mail.com>
        Perl threads <mail@mail.com>
    Re: Perl threads <ThomasKratz@REMOVEwebCAPS.de>
    Re: perl2exe can't locate DBI.pm <ittyspam@yahoo.com>
    Re: perl2exe can't locate DBI.pm (Bunny)
        Printing in Perl <bsoist@sdf.lonestar.org>
    Re: Printing in Perl <nobull@mail.com>
    Re: Reseting numbered variables <nobull@mail.com>
    Re: reverse search modifier <nobull@mail.com>
    Re: seek help with regular expressions syntax (Mad Scientist Jr)
    Re: Simple Sort Keys Question from a Simpleton (Bumble Bee Boy 2 at Google)
    Re: Simple Sort Keys Question from a Simpleton <ittyspam@yahoo.com>
    Re: Simple Sort Keys Question from a Simpleton <jwillmore@remove.adelphia.net>
    Re: stripping out ASCII chars using regexp? (Greg)
    Re: stripping out ASCII chars using regexp? (Greg)
    Re: Variable interpolation in regular expressions (Jay Tilton)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 18 Mar 2004 18:24:59 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: a doubt in unicode sub-properties
Message-Id: <u9oequgghw.fsf@wcl-l.bham.ac.uk>

"yamini" <yamini_rajan@nospam.com> writes:

> i want to minus the words "of ","in" from the \p{Ll} class.
 
> [\p{Ll}&&[^ofin]] i tried with this.but its not working.
> can anyone help me in tracing the mistake i have done here?

As MJD says you: can't just make shit up and expect the
computer to know what you mean, retardo!

Hint: The words "of" and "in" are not single characters even in unicode.

Think you are looking for negative lookahead assertions.

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


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

Date: 18 Mar 2004 09:43:55 -0800
From: tvfw@hotmail.com (benny s.)
Subject: Amulating post back to a .net server
Message-Id: <1ffea2a.0403180943.917cf43@posting.google.com>

Is there a way to repost a form that I just recieved with all the
information
back to the server with a change of one of the fields.

For example I have an html file with a form one of the hidden fields
is
<input type="hidden" name="thisPage" value="1">

now when I post it the first time I get page 1 on the second post I
want to post the same result from the last request with a change to
the value of thisPage
now beeing 2

Thanks


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

Date: 18 Mar 2004 18:43:07 GMT
From: Roel van der Steen <roel-perl@st2x.net>
Subject: Re: Amulating post back to a .net server
Message-Id: <slrnc5jrdv.ev.roel-perl@localhost.localdomain>

On Thu, 18 Mar 2004 at 17:43 GMT, benny s. <tvfw@hotmail.com> wrote:
> For example I have an html file with a form one of the hidden fields
> is
><input type="hidden" name="thisPage" value="1">

Are you sure you're on the right newsgroup? This one is
about Perl.


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

Date: 18 Mar 2004 18:02:46 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: capitalizing each word in an array
Message-Id: <u91xnqhw3d.fsf@wcl-l.bham.ac.uk>

laredotornado@zipmail.com (D. Alvarado) writes:

> Hi, I have an array of strings and it would be cool if, in one line, I
> could  capitalize all characters in each word of the array.
                                                       ^^^^^

> @upper_case_arr = func( @lower_case_arr );

That doesn't change stuff _in_ the array it makes a copy changing it
as it goes.

If you want to keep the original array about then that's cool but if
you actually want to act directly on an array then use for.

s/\b(\w)/\U$1/g for @array;


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


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

Date: 18 Mar 2004 08:23:34 -0800
From: ashkan21@hotmail.com (Ashkan)
Subject: converting an evaluated expression to a literal
Message-Id: <16902fb8.0403180823.3700286e@posting.google.com>

Hi,

I'm performing pattern substitution and I'm having some problems when
my pattern contains the following structure: "[3]".

Here is a snippet of my code:

while ($count ne 0) {
    $file[$count] =~ s#$value[$val_count]#sub[$val_count]#g;
    $count--;
}
Is there any way for the $value[$val_count] to be evaluated, then the
output be treated as a literal?

my search patterns will be things such as 'abc[2]'.
Thanks.


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

Date: Thu, 18 Mar 2004 11:38:30 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: converting an evaluated expression to a literal
Message-Id: <20040318113621.R21521@dishwasher.cs.rpi.edu>

On Thu, 18 Mar 2004, Ashkan wrote:

> Hi,
>
> I'm performing pattern substitution and I'm having some problems when
> my pattern contains the following structure: "[3]".
>
> Here is a snippet of my code:
>
> while ($count ne 0) {
>     $file[$count] =~ s#$value[$val_count]#sub[$val_count]#g;
>     $count--;
> }
> Is there any way for the $value[$val_count] to be evaluated, then the
> output be treated as a literal?

s/\Q$value[$val_count]\E/sub[$val_count]/g;

the \Q ... \E syntax escapes (backslashes) all 'special' characters in the
string, rendering [ and ] as plain old brackets, so they no longer have
their special meaning in a regexp.

Paul Lalli


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

Date: Thu, 18 Mar 2004 09:26:14 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: CPAN module install error
Message-Id: <pan.2004.03.18.14.26.12.108099@remove.adelphia.net>

On Wed, 17 Mar 2004 13:26:11 -0800, Page wrote:

> I tried to install a module on my WinXP machine using the CPAN
> installer.  Everything seemed to go well, but the modules aren't being
> installed.  Can someone tell me what I need to do to remedy the
> following error?
> 
> cpan> install XML::NamespaceSupport
> Running install for module XML::NamespaceSupport
> Running make for R/RB/RBERJON/XML-NamespaceSupport-1.08.tar.gz
>   Is already unwrapped into directory
> \.cpan\build\XML-NamespaceSupport-1.08
>   Has already been processed within this session
> Running make test
> 'test' is not recognized as an internal or external command,
> operable program or batch file.
>    test -- NOT OK
> Running make install
>   make test had returned bad status, won't install without force
>  
> cpan>

First, type 'clean XML::NamespaceSupport', then do 'install
XML::NamespaceSupport'.  It looks like you (or someone else) tried to
install this module before and it failed.  This time, keep an eye on the
output - there may be some reason why the module won't install.

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
Conscience is the inner voice that warns us somebody is looking  
-- H. L. Mencken 



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

Date: Thu, 18 Mar 2004 09:48:54 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Empty hash key produces funky results
Message-Id: <Pine.A41.4.58.0403180947190.13464@ginger.libs.uga.edu>

On Wed, 17 Mar 2004, Aaron DeLoach wrote:

> Consider the following (an empty key value):
>
> my $str = &test('1',"one", '2',"two", '3',, '4',"four");
>
> print $str;
>
> sub test
> {
>  my %in = @_;
>  my ($str, $k, $v);
>  while (($k,$v)=each %in)
>  {
>    if ($v)
>    {
>    $str.="$k=>$v\n";
>    }
>  }
>  return $str;
> }
>
> Outputs the following:
>
> 1=>one
> 3=>4
> 2=>two

It seems you neglected to note this warning in the output:

Odd number of elements in hash assignment ...

You do have warnings enabled, right?

Regards,

Brad


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

Date: Thu, 18 Mar 2004 09:35:00 -0500
From: Richard Morse <remorse@partners.org>
Subject: Re: How do you reference web form elements?
Message-Id: <remorse-34BA34.09350018032004@plato.harvard.edu>

[Please don't top-post -- in this forum, it is considered rude...]

In article <PI56c.119033$IF6.3975787@ursa-nb00s0.nbnet.nb.ca>,
 "Brett Baisley" <baisley@hotmail.com.REMOVETHIS> wrote:

> "Richard Morse" <remorse@partners.org> wrote in message
> news:remorse-CD7C72.18422517032004@plato.harvard.edu...
> >
> > Why do you think that you need to call Perl functions from javascript?
> 
> Because I need to get results from a database and I know that Javascript
> can't do it, as its client side, or if you can, I'm not sure how. I do know
> how to with Perl tho.
> 
> But, I'm reworking my stragety, so don't worry about it. Thanks for the
> input tho, I understand the concepts better now.

If the database is on the server, you would need to have the user submit 
a form (or perhaps click a link), and regenerate the page with the new 
data.

However, this topic has now moved completely off-topic...

Hope I helped a bit..

Ricky


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

Date: Thu, 18 Mar 2004 15:49:30 GMT
From: Ala Qumsieh <xxala_qumsiehxx@xxyahooxx.com>
Subject: Re: HOW TO PARSE A VAST FILE!
Message-Id: <eyj6c.25718$tw5.16996@newssvr29.news.prodigy.com>

news.hinet.net wrote:
> I must parse 500M's logfile!
 > ....
> ps: its spend 3 hours to complete now!

I have scripts that parse files larger than this, and it takes less than 
5 minutes. It depends on what you mean by "parse", i.e. what information 
you are trying to extract from the file and how you're doing it.

We would be able to help you better if you show us your code that parses 
the file. I have a feeling you're doing something sub-optimal somewhere.

--Ala



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

Date: Thu, 18 Mar 2004 16:50:56 +0000
From: Peter Hickman <peter@semantico.com>
Subject: Re: HOW TO PARSE A VAST FILE!
Message-Id: <4059d370$0$2565$afc38c87@news.easynet.co.uk>

news.hinet.net wrote:

> I must parse 500M's logfile!
> How to do this job while speed up.
> Someone can give me good idea for this job.
> Split file to small one and use fork to do that or
> other method can make good result.
> 
> 
> ps: its spend 3 hours to complete now!

Ok this is trumpet blowing but if the log file is an apache log file 
then there is Apache::LogRegex. Which processes a logfile and returns 
you a hash of the data on each line. Pretty fast (if I say so myself) 
and available on CPAN.


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

Date: Fri, 19 Mar 2004 00:36:31 +0800
From: "news.hinet.net" <luke@program.com.tw>
Subject: Re: HOW TO PARSE A VAST FILE!
Message-Id: <c3ckav$oc4@netnews.hinet.net>

really??

i have send some information to your mailbox!

"Ala Qumsieh" <xxala_qumsiehxx@xxyahooxx.com> ???
news:eyj6c.25718$tw5.16996@newssvr29.news.prodigy.com ???...
> news.hinet.net wrote:
> > I must parse 500M's logfile!
>  > ....
> > ps: its spend 3 hours to complete now!
>
> I have scripts that parse files larger than this, and it takes less than
> 5 minutes. It depends on what you mean by "parse", i.e. what information
> you are trying to extract from the file and how you're doing it.
>
> We would be able to help you better if you show us your code that parses
> the file. I have a feeling you're doing something sub-optimal somewhere.
>
> --Ala
>




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

Date: Fri, 19 Mar 2004 01:05:53 +0800
From: "news.hinet.net" <luke@program.com.tw>
Subject: Re: HOW TO PARSE A VAST FILE!
Message-Id: <c3cku1$2ev@netnews.hinet.net>

It is not  apache log or standard logfile.


logfile:

163.22.3.7      2003/06/28 0011:00:42 PASSED
http://proxy.ncnu.edu.tw/cgi-bin/squidGuard.cgi?clientaddr=163.22.28.128&clientname=ip128.puli28.ncnu.edu.tw&clientuser=&clientgroup=general-clients&targetgroup=moe&url=http://gatorcme.gator.com/gatorcme/autoupdate/precisiontime.ini
163.22.3.7      2003/06/28 0011:00:42 PASSED
http://163.22.3.7/gatorcme/autoupdate/precisiontime.ini
163.22.3.7      2003/06/28 0011:00:43 PASSED
http://proxy.ncnu.edu.tw/cgi-bin/squidGuard.cgi?clientaddr=163.22.9.25&clientname=ip025.puli09.ncnu.edu.tw&clientuser=&clientgroup=general-clients&targetgroup=moe&url=http://gatorcme.gator.com/gatorcme/autoupdate/installdatemanager.exe
163.22.3.7      2003/06/28 0011:00:43 PASSED
http://163.22.3.3/gatorcme/autoupdate/installdatemanager.exe
218.172.162.134 2003/06/28 0011:00:44 PASSED
http://liveupdate.symantecliveupdate.com/autoupdt.trg
218.172.162.134 2003/06/28 0011:00:44 PASSED
http://202.239.172.95/autoupdt.trg


i want to find  ip(163.22.3.7  218.172.162.134 ...) that are not exist in
mysql.
if it is exist in db then reject or insert into db.
the procedure only  do this job.


please help!



"Peter Hickman" <peter@semantico.com> ???
news:4059d370$0$2565$afc38c87@news.easynet.co.uk ???...
> news.hinet.net wrote:
>
> > I must parse 500M's logfile!
> > How to do this job while speed up.
> > Someone can give me good idea for this job.
> > Split file to small one and use fork to do that or
> > other method can make good result.
> >
> >
> > ps: its spend 3 hours to complete now!
>
> Ok this is trumpet blowing but if the log file is an apache log file
> then there is Apache::LogRegex. Which processes a logfile and returns
> you a hash of the data on each line. Pretty fast (if I say so myself)
> and available on CPAN.




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

Date: 18 Mar 2004 18:07:39 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: HOW TO PARSE A VAST FILE!
Message-Id: <slrnc5jpbb.1c.xx087@smeagol.ncf.ca>

news.hinet.net <luke@program.com.tw> wrote:
[...]
>  i want to find  ip(163.22.3.7  218.172.162.134 ...) that are not exist in
>  mysql.
>  if it is exist in db then reject or insert into db.
>  the procedure only  do this job.

Are you doing a db insert every time you see a new IP?
You should store the info until you finish reading the file, 
then do a bulk insert.

-- 
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca


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

Date: Thu, 18 Mar 2004 18:31:20 GMT
From: "Ala Qumsieh" <xxala_qumsiehxx@xxyahooxx.com>
Subject: Re: HOW TO PARSE A VAST FILE!
Message-Id: <YVl6c.25748$TH6.18455@newssvr29.news.prodigy.com>

"news.hinet.net" <luke@program.com.tw> wrote in message
news:c3ckav$oc4@netnews.hinet.net...

Out of respect to others in this ng, please adhere to its customs, and do
not top-post your replies.

> "Ala Qumsieh" <xxala_qumsiehxx@xxyahooxx.com> ???
> news:eyj6c.25718$tw5.16996@newssvr29.news.prodigy.com ???...
> > news.hinet.net wrote:
> > > I must parse 500M's logfile!
> >  > ....
> > > ps: its spend 3 hours to complete now!

 ...

> > We would be able to help you better if you show us your code that parses
> > the file. I have a feeling you're doing something sub-optimal somewhere.

> really??
>
> i have send some information to your mailbox!

I'm not sure whether this comment is sarcastic or not, but I'll bite. My
posted email is not a true one, although any sufficiently intelligent human
can deduce my real one very easily just by looking at it.

Moreover, it's better to post questions on this newsgroup (obviously I do
read this group regularly), so you can get more people to help you. If you
think that your code is too good to show to us, then I'm afraid you will
have a very hard time getting the help you're looking for.

--Ala




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

Date: Thu, 18 Mar 2004 18:55:08 GMT
From: Kirk Strauser <kirk@strauser.com>
Subject: Re: HOW TO PARSE A VAST FILE!
Message-Id: <87y8pykmxk.fsf@strauser.com>

=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At 2004-03-18T17:05:53Z, "news.hinet.net" <luke@program.com.tw> writes:

> i want to find ip(163.22.3.7 218.172.162.134 ...) that are not exist in
> mysql.  if it is exist in db then reject or insert into db.  the procedure
> only do this job.

Define the IP field in that table as unique, attempt to batch-insert
everything you've found, and let MySQL handle the uniqueness itself.  It's
almost guaranteed to be more efficient than you doing it by hand.
=2D --=20
Kirk Strauser
The Strauser Group
Open. Solutions. Simple.
http://www.strausergroup.com/
=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAWe/v5sRg+Y0CpvERAgFEAJ9dnO1lMUlWdZNyL0yunV2NoCeJCACdGFp9
3t5efmg4uWAmyRyOQtXyA68=3D
=3Dxi9D
=2D----END PGP SIGNATURE-----


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

Date: 18 Mar 2004 08:15:40 -0800
From: slkleine@hotmail.com (Steve The Geek)
Subject: Re: Multiple compares -- TMTOWTDI
Message-Id: <863f122c.0403180815.57778a33@posting.google.com>

Between the advice given (and taken!) and using Parl.exe to crush it
into an EXE, it's running amazingly well on the Win2000 boxen I'm
forced to use. 20K lines of logfiles in less than 10 seconds is a Good
Thing.

Another set of "best practices" questions on the same script:
<code snippet>

sub RemoveIrrelevantCodes
{$ReturnCode = undef;  #Initialize $ReturnCode
  if ($DataLine[7] eq "RMON") #ENTERPRISE, Removes RMON exceeded
    {return;}
  if (($DataLine[7] eq "Cabletron")) #ENTERPRISE
  {
    if ($DataLine[15] eq "418") #Remove Port up sub-filter
    {return;}
    if ($DataLine[15] eq "419") #Remove Port down sub-filter
    {return;}
    if ($DataLine[14] eq "6") #Generic TRAP number
    {
      if ($DataLine[15] eq "1201")  #Recommended removal for "Physical
Container Changes" occurring on 9000 chassis by Enterasys KB article
tb0164-1
      {return;}
     }
  }
    $ReturnCode = join (",", @DataLine[1,2,5,7..9,14,15]);
}

</code snippet>

I know the semicolon isn't required for return. Is it good practice to
put it in? How about changing return; to return(); ?

Is the $ReturnCode = undef necessary, since any {return;} sets it to
undef anyway?

Is there any advantage (speed or legibility) to creating another
variable name for the $DataLine[xx] scalars, e.g. $Enterprise =
$DataLine[7], $GenericTrap = $DataLine[14], $SpecificTrap =
$DataLine[15], etc.? A hash seems (to this novice) to be the way to go
in that case...

Are comments as a suffix (as listed in the script) acceptable?

Thanks again!

Steve the (Perl scripting without $PHB consent) Geek


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

Date: Thu, 18 Mar 2004 11:43:48 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Multiple compares -- TMTOWTDI
Message-Id: <20040318113849.F21521@dishwasher.cs.rpi.edu>

On Thu, 18 Mar 2004, Steve The Geek wrote:

> Between the advice given (and taken!) and using Parl.exe to crush it
> into an EXE, it's running amazingly well on the Win2000 boxen I'm
> forced to use. 20K lines of logfiles in less than 10 seconds is a Good
> Thing.
>
> Another set of "best practices" questions on the same script:
> <code snippet>
>
> sub RemoveIrrelevantCodes
> {$ReturnCode = undef;  #Initialize $ReturnCode
>   if ($DataLine[7] eq "RMON") #ENTERPRISE, Removes RMON exceeded
>     {return;}
>   if (($DataLine[7] eq "Cabletron")) #ENTERPRISE
>   {
>     if ($DataLine[15] eq "418") #Remove Port up sub-filter
>     {return;}
>     if ($DataLine[15] eq "419") #Remove Port down sub-filter
>     {return;}
>     if ($DataLine[14] eq "6") #Generic TRAP number
>     {
>       if ($DataLine[15] eq "1201")  #Recommended removal for "Physical
> Container Changes" occurring on 9000 chassis by Enterasys KB article
> tb0164-1
>       {return;}
>      }
>   }
>     $ReturnCode = join (",", @DataLine[1,2,5,7..9,14,15]);
> }
>
> </code snippet>
>
> I know the semicolon isn't required for return. Is it good practice to
> put it in? How about changing return; to return(); ?

the semi colon is personal preference.  It makes no difference.  changing
from return to return() actually is a very minor semantic change.  In the
first case, you're returning undef.  In the second, you're returning an
empty list.  Were I writing this, I would probably get rid of all these
extra parens and braces:

return if $DataLine[7] eq 'RMON';
etc

> Is the $ReturnCode = undef necessary, since any {return;} sets it to
> undef anyway?

Didn't we just have a thread about this.  All perl variables are
automatically initialized to undef.  There is never a reason to do it
again explicitly.  Your question's phrasing makes me double-take though...
returning undef does not set $ReturnCode to anything.  It sets the
variable to which the subroutine call is assinged to undef, however.

> Is there any advantage (speed or legibility) to creating another
> variable name for the $DataLine[xx] scalars, e.g. $Enterprise =
> $DataLine[7], $GenericTrap = $DataLine[14], $SpecificTrap =
> $DataLine[15], etc.? A hash seems (to this novice) to be the way to go
> in that case...

For what reason?  What would you do with these new variables?

> Are comments as a suffix (as listed in the script) acceptable?

Not when they make your lines run more than 80 characters long, they're
not.  That's just nasty looking.

Paul Lalli


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

Date: Thu, 18 Mar 2004 10:17:49 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Perl script to transfer file via https
Message-Id: <pan.2004.03.18.15.17.47.606774@remove.adelphia.net>

On Wed, 17 Mar 2004 23:47:58 -0800, c0rum_z wrote:

> I'm just very new to perl and I would like to transfer file from a
> unix machine to a web server with a servlet that could accept file
> 
> Is there any available script that I could use?

Probably.  Did you exhaust your searches yet ... there's a lot of places
to look :-)  Or, you could write your own :-)

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
Ask five economists and you'll get five different explanations
(six if one went to Harvard).   -- Edgar R. Fiedler 



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

Date: Thu, 18 Mar 2004 16:00:14 -0000
From: "bob" <mail@mail.com>
Subject: perl Threads
Message-Id: <b36dnWxz2t-WVcTdSa8jmA@karoo.co.uk>

I am attempting to write a simple threaded application using threads.
I wanted to user data queue to pass data between threads but this doesnt
seem to work.
My code is below if anyone can help
Cheers


while(1) {
        print "Thred 2 created\n";
        $DataQueue->enqueue("A", "B", "C");
        $thr = new Thread \&sample_sub;
        while (1) {
                $DataQueue->enqueue("A", "B", "C");
                print "IM HERE\n";
                yield();
                sleep(1);
        }
$thr->jobs();
exit;
}

sub sample_sub {
my($DataElement);
        while(1){
print Dumper($DataQueue);
        print $DataQueue->pending,"\n";;
        while ($DataElement = $DataQueue->dequeue_nb
) {
        if (ref($DataElement)) {
            print "Popped $$DataElement off the queue\n";
        } else {
            print "Popped $DataElement off the queue\n";
                }
        }
        yield();
        sleep(1);
        }
}




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

Date: Thu, 18 Mar 2004 16:01:05 -0000
From: "bob" <mail@mail.com>
Subject: Perl threads
Message-Id: <b36dnW9z2t-QVcTdSa8jmA@karoo.co.uk>

I am attempting to write a simple threaded application using threads.
I wanted to user data queue to pass data between threads but this doesnt
seem to work.
My code is below if anyone can help
Cheers


while(1) {
        print "Thred 2 created\n";
        $DataQueue->enqueue("A", "B", "C");
        $thr = new Thread \&sample_sub;
        while (1) {
                $DataQueue->enqueue("A", "B", "C");
                print "IM HERE\n";
                yield();
                sleep(1);
        }
$thr->jobs();
exit;
}

sub sample_sub {
my($DataElement);
        while(1){
print Dumper($DataQueue);
        print $DataQueue->pending,"\n";;
        while ($DataElement = $DataQueue->dequeue_nb
) {
        if (ref($DataElement)) {
            print "Popped $$DataElement off the queue\n";
        } else {
            print "Popped $DataElement off the queue\n";
                }
        }
        yield();
        sleep(1);
        }
}





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

Date: Thu, 18 Mar 2004 19:06:44 +0100
From: Thomas Kratz <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: Perl threads
Message-Id: <4059e65a.0@juno.wiesbaden.netsurf.de>

bob wrote:

> I am attempting to write a simple threaded application using threads.
> I wanted to user data queue to pass data between threads but this doesnt
> seem to work.
> My code is below if anyone can help
> Cheers

Please read the posting guidelines posted regularly to this group. After 
that please post a *small* and *complete* script that demonstrates the 
problem you are having.

The code you posted doesn't even compile. And please fix your indenting.

Thomas

-- 
open STDIN,"<&DATA";$=+=14;$%=50;while($_=(seek( #J~.> a>n~>>e~.......>r.
STDIN,$:*$=+$,+$%,0),getc)){/\./&&last;/\w| /&&( #.u.t.^..oP..r.>h>a~.e..
print,$_=$~);/~/&&++$:;/\^/&&--$:;/>/&&++$,;/</  #.>s^~h<t< ..~. ...c.^..
&&--$,;$:%=4;$,%=23;$~=$_;++$i==1?++$,:_;}__END__#....>>e>r^..>l^...>k^..


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

Date: Thu, 18 Mar 2004 10:17:15 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: perl2exe can't locate DBI.pm
Message-Id: <20040318101447.T21521@dishwasher.cs.rpi.edu>

On Thu, 17 Mar 2004, Bunny wrote:

> Date: 17 Mar 2004 22:38:02 -0800
> From: Bunny <bunny1112@yahoo.com>
> Newsgroups: comp.lang.perl.misc
> Subject: perl2exe can't locate DBI.pm
>
> Hi!
> I have perl5.00503 loaded on my Linux and I have downloaded and loaded
> perl2exe V1.09U on Linux 6.1
>
> I have written a small code for extracting data from database.  Now my
> perl script runs fine and an appropriate output is also rendered by
> the web browser.
>

Have you tried looking at the user's manual for perl2exe, or did you
consider asking the world for help your first recourse instead?

http://www.indigostar.com/pxman.htm
FAQ #15:  How to use DBI with Perl2Exe

Paul Lalli



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

Date: 18 Mar 2004 10:20:12 -0800
From: bunny1112@yahoo.com (Bunny)
Subject: Re: perl2exe can't locate DBI.pm
Message-Id: <d4a4789a.0403181020.49215564@posting.google.com>

Paul Lalli <ittyspam@yahoo.com> wrote in message news:<20040318101447.T21521@dishwasher.cs.rpi.edu>...
> On Thu, 17 Mar 2004, Bunny wrote:
> 
> > Date: 17 Mar 2004 22:38:02 -0800
> > From: Bunny <bunny1112@yahoo.com>
> > Newsgroups: comp.lang.perl.misc
> > Subject: perl2exe can't locate DBI.pm
> >
> > Hi!
> > I have perl5.00503 loaded on my Linux and I have downloaded and loaded
> > perl2exe V1.09U on Linux 6.1
> >
> > I have written a small code for extracting data from database.  Now my
> > perl script runs fine and an appropriate output is also rendered by
> > the web browser.
> >
> 
> Have you tried looking at the user's manual for perl2exe, or did you
> consider asking the world for help your first recourse instead?
> 
> http://www.indigostar.com/pxman.htm
> FAQ #15:  How to use DBI with Perl2Exe
> 
> Paul Lalli

Thanks Paul Lalli!!
I am sure you would not have gone through my code properly and thats
you had raised this question.. I had gone through the pxman.htm file
already and had added the statement "use DBI;"  I also tried adding
the line "use DBD::mysql;" in my script but still getting the same
errors?????


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

Date: Thu, 18 Mar 2004 18:46:24 +0000 (UTC)
From: Bill Soistmann <bsoist@sdf.lonestar.org>
Subject: Printing in Perl
Message-Id: <slrnc5jrjt.cbn.bsoist@sdf.lonestar.org>

Greetings
I have not used perl in some time and I was wondering if I could ask a 
quick question.

Are parenthesis now required for printing? I know that had not always
been the case.

If so, I have another quick question
Is there an option to make old scripts work.

-- 
Bill Soistmann
Always try to do things in chronological order; it's less confusing
that way.


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

Date: 18 Mar 2004 18:58:09 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Printing in Perl
Message-Id: <u9ish2geym.fsf@wcl-l.bham.ac.uk>

Bill Soistmann <bsoist@sdf.lonestar.org> writes:
> 
> Are parenthesis now required for printing?

Way it really quicker to post to Usenet than just to try it?

perl -e"print 666"

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


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

Date: 18 Mar 2004 18:11:39 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Reseting numbered variables
Message-Id: <u9wu5igh44.fsf@wcl-l.bham.ac.uk>

"gnari" <gnari@simnet.is> writes:

> "Toni" <ante.cepic@siemens.com> wrote in message
> news:8b22fe57.0403180050.3cbb584a@posting.google.com...

> >     $result =~ /Users of $feature: Total of (\d+) licenses issued/;
> >     $total_lic = $1;

> think about $1 as part of the //, that should not be used
> unless the // succeeds.
> so you code should contain:
>       if ($result =~ /Users of $feature: Total of (\d+) licenses issued/) {
>           $total_lic = $1;
>       }

> now you should not ask "How do I reset $1 ?"
> but "How do I reset $total_lic ?"
> 
> one way would be an 'else {} '

A more direct way would be not to use $1:

 ($total_lic) = $result =~ /Users of $feature: Total of (\d+) licenses issued/;

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


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

Date: 18 Mar 2004 18:16:58 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: reverse search modifier
Message-Id: <u9smg6ggv9.fsf@wcl-l.bham.ac.uk>

blacraven@hotmail.com (S Raven) writes:

> Is there is any reverse search modifier that can be used in regexes?

No.

> Something like, $text =~ s/me/mine/r;
> I have not seen anything like that before, so was wondering whether
> there was one. Can anyone please clarify.

When I first encountered regex I thought such a thing would be good
but now I know more about regex I realise that understanding the
semantics of such a modifer would be very complex.

Anything you could achive can be equally done with greedy/non-greeded
and/or lookahead/lookbehind.  Or as a last resort simply reverse the
string.

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


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

Date: 18 Mar 2004 10:46:57 -0800
From: usenet_daughter@yahoo.com (Mad Scientist Jr)
Subject: Re: seek help with regular expressions syntax
Message-Id: <7a93f3c4.0403181046.2508f1fc@posting.google.com>

s!<LI><FONT FACE="[^"]*" SIZE="[^"]*"
COLOR="[^"]*"></FONT></LI>!<P>&nbsp;</P>!i;

thanks for the reply, i figured it out, this works: 

<LI><FONT FACE="[^"]*"\s*SIZE="[^"]*"\s*COLOR="[^"]*"></FONT></LI>

the \s* takes care of any white space. 
i already know quote will always be used for attributes 
and the attributes will be in that order 
(of course i can always ghetto it and use 3^3=9 reg expressions to
catch all cases, and use something like ["|'] to "OR" the
quote/apostrophe).

the above was done for .net's regex object, so the syntax may be
different. what are the s! are !i; for in the example you posted?


> That assumes that your attributes are always " quoted, and that
> there are never any " characters within those strings.
> Also that the attributes always appear in the same order, always
> are separated by a single space character, etc.  In other words,
> it's "brittle" code.  Properly, you should parse the HTML,
> perhaps with the HTML::Parser module, and deal with the results
> of the parse.


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

Date: 18 Mar 2004 07:08:19 -0800
From: bumblebeeboy2@hotmail.com (Bumble Bee Boy 2 at Google)
Subject: Re: Simple Sort Keys Question from a Simpleton
Message-Id: <d79474fe.0403180708.6d2ed667@posting.google.com>

i've managed to get a bit further but stuck still, i'm a bit confused
about it all? the script should check to see if a person already
exists, if they do it adds their sales numbers together so there is
just the 1 entry for them. then sort by the $totsales figure and
output to a file. at the moment it seems to be sorting by surname, and
i can't find what is happening to totsales, or how to add it into the
array with firstname and surname?

(a very confused newbie who would greatly appriciate any help!!)

#!/usr/bin/perl -w

%sales=();

open (FP1, "<sales.txt") or die "Unable to open sales file!\n";
open (FP2, ">best.txt") or die "Unable to create output file!\n";

while ($line = <FP1>)
{
	@fields = split (" ", $line);
	$surname=$fields[0];
	$firstname=$fields[1];
	$totsales=$fields[2];


	if (defined $sales{"$surname $firstname"})
	{
		$sales{"$surname $firstname"} += $totsales;
	}

	else
	{
		$sales{"$surname $firstname"} = $totsales;
	}

}

foreach $person (sort keys %sales)
{
    print FP2 "$totsales ($person)\n";
}

close FP1;
close FP2;


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

Date: Thu, 18 Mar 2004 10:31:36 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Simple Sort Keys Question from a Simpleton
Message-Id: <20040318102743.G21521@dishwasher.cs.rpi.edu>

On Thu, 18 Mar 2004, Bumble Bee Boy 2 at Google wrote:

> i've managed to get a bit further but stuck still, i'm a bit confused
> about it all? the script should check to see if a person already
> exists, if they do it adds their sales numbers together so there is
> just the 1 entry for them. then sort by the $totsales figure and
> output to a file. at the moment it seems to be sorting by surname, and
> i can't find what is happening to totsales, or how to add it into the
> array with firstname and surname?
>
> (a very confused newbie who would greatly appriciate any help!!)
>
> #!/usr/bin/perl -w
>
> %sales=();
>
> open (FP1, "<sales.txt") or die "Unable to open sales file!\n";
> open (FP2, ">best.txt") or die "Unable to create output file!\n";
>
> while ($line = <FP1>)
> {
> 	@fields = split (" ", $line);
> 	$surname=$fields[0];
> 	$firstname=$fields[1];
> 	$totsales=$fields[2];
>
>
> 	if (defined $sales{"$surname $firstname"})
> 	{
> 		$sales{"$surname $firstname"} += $totsales;
> 	}
>
> 	else
> 	{
> 		$sales{"$surname $firstname"} = $totsales;
> 	}
Don't do this.  Hash keys auto-vivify.  There's no reason to test for
defindness.  Eliminate these 9 lines and replace with the one line
$sales("$surname $firstname"} += $totsales;

>
> }
>
> foreach $person (sort keys %sales)
> {
>     print FP2 "$totsales ($person)\n";
> }
>
> close FP1;
> close FP2;
>


Okay.  Two big problems here.  One, you're sorting by key (which in your
hash is the string composed of the surname followed by the first name).
You want to sort by value.  Do
perldoc -q value
and read the third entry.

Second, you're randomly pulling the variable $totsales out of nowhere in
the last foreach loop.  This foreach loop is going through the keys of
%sales and assigning each to the variable $person.  What you're calling
the total sales should be the value of the hash at this key:

print FP2 "$sales{$person} ($person)\n";

Hope this helps,
Paul Lalli


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

Date: Thu, 18 Mar 2004 10:31:41 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Simple Sort Keys Question from a Simpleton
Message-Id: <pan.2004.03.18.15.31.39.585262@remove.adelphia.net>

On Thu, 18 Mar 2004 07:08:19 -0800, Bumble Bee Boy 2 at Google wrote:
[ ... ]

> #!/usr/bin/perl -w

  use strict;
 
[ ... ]

> 	if (defined $sales{"$surname $firstname"})

        if (exists $sales{"$surname $firstname"})

[ ... ]

You are trying to see if the person *exists* in the 'sales' hash.  So, use
'exists' :-)  You may want to make life a little easier for yourself by
using 'sprintf ' to make the name.  For example ...

my $salesperson = sprintf "%s %s", $surname, $firstname;
if ( exists $sales{$salesperson}(
 ...
}

Now, if you need to print or use the salesperson again, you don't have to
do something  like "$surname $firstname" all the time :-)

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
Time flies like an arrow Fruit flies like a banana 




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

Date: 18 Mar 2004 09:13:18 -0800
From: djbitchpimp@snowboard.com (Greg)
Subject: Re: stripping out ASCII chars using regexp?
Message-Id: <7e312ede.0403180913.4b459263@posting.google.com>

Bob Walton <invalid-email@rochester.rr.com> wrote in message news:<40590571.7090607@rochester.rr.com>...
> Could you give us the URL of an example web page?  And the (minimal) 
> code that grabs it and runs HTML::TableExtract?  That is so we can run 
> it ourselves and see what is really going on.  For example, is the above 
> the exact literal string which is generated?  For debugging, that is 
> important to know.

#! /usr/bin/perl -w

use strict ;
use LWP::Simple ;
use HTML::TableExtract ;
 
my $doc ;
my $url = "http://wants.musicstack.com/" ;
my $count = 0 ;

my @artists ;
my @titles ;
my @formats ;
my @prices ;
my @time ;
my @country ;


$doc = get ($url) ;

for (my $i = 3; $i < 10; $i++) {

        my $te = new HTML::TableExtract( depth => 0, count => $i ) ;
        $te->parse($doc) ;
 
        my $ts ;
        foreach $ts ($te->table_states) {
                my $row ;
                foreach $row ($ts->rows) {
                        my $line = join (',', @$row) ;
                        print "$line\n" ;
                        my @line = split (',', $line) ;
                        my $word ;
                        
######################### THIS IS WHERE I AM CLEANING UP THE NUMBER
FIELD
                        foreach $word (@line) { # chop off ASCII 160
chars
                                #chop $word
                                #$_ = $word ;
                                #tr/\177-\377//d ;
                                #s/\&#65533//g ;
                                #$word =~ tr/[^0-9.]//d;
                                #if($line[6] =~ m/(\d+\.?\d*)/) {
                                #       $line[6] = $1 ;
                                #}
                        }
                        
                        # line [6] contains number field with extra
wierd chars
                        my @chars ;
                        my @chars = split ('', $line [6]) ;
                        foreach my $char (@chars) {
                                print "$char ";
                                print ord ($char) ;
                                print "\n" ;
                        }
 
                       
                        if ($line [6] >= 75) {
                                $artists [$count] = stripChars ($line
[1]) ;
                                $titles [$count] = stripChars ($line
[2]) ;
                                $formats [$count] = $line [5] ; # [5]
                                $prices [$count] = $line [6] ; # [6]
                                $time [$count] = $line [8] ; # [8]
                                $country [$count] = $line [9] ; # [9]
                                $count++ ;
                        }
                }
        }
}

# print out results
for (my $i = 0; $i < $count; $i++) {
       print "[$i]\n" ;
       print $artists [$i]. "\n" ;
       print $titles [$i] . "\n" ;
       print $formats [$i] . "\n" ;
       print $prices [$i] . "\n" ;
       print $time [$i] . "\n" ;
       print $country [$i] . "\n" ;
 
       print "ARTIST: $artists[$i] TITLE: $titles[$i] PRICE:
\$$prices[$i]\n" ;
}

sub stripChars {
 
        $_ = $_[0] ;
 
        s/\bvarious\b\s//i ;
        s/\bartists\b//i ;
        s/\bpresents\b\s//i ;
        s/\bof\b\s//i ;
        s/\bthe\b\s//i ;
        s/\bat\b\s//i ;
        s/\band\b\s//i ;
        s/\betc\b\s//i ;
        s/\bin\b\s//i ;
        s/\bv\\a\b//i ;
        s/\bv\/a//i ;
        s/\W/ / ;
        s/\& // ;
        s/\// / ;
        s/\\/ / ;
        s/\(.*\) ?// ;
        #s/\(.*\)// ;
        s/\(.*$// ;
        s/\s.$// ;
        s/ . / /g ;
        s/^. // ;
 
        print "STRIPPED: $_\n" ;
 
        return $_ ;
}

> So $char has the value '&#65533;' from the execution of 
> split('',$line[6])?  That shouldn't (couldn't?) be.  Again, some way to 
> sample your actual data and actual code would help tons.  Also in this 
> case, the '160' is coming from whatever the first character of $char is.

All of the symbols got converted to "&#65533" when I pasted my output
into my web browser. In perl it just shows up as an empty space.


> Access to some real sample data would be a big help in that regard.

OK I pasted some working code above.

> Another approach would be to use a regexp that matches everything you 
> *want* to see and ignores the rest.  Maybe something like:
> 
>     if($line[6]=~m/(\d+\.?\d*)/){
>         $line[6]=$1;
>     }
>     else{
>         die "Oops, wipeout due to bad number blah blah ...";
>     }

This approach does do what I wanted so it effectively fixed the
problem, but for interest's sake it would be cool to figure out why it
won't strip the ASCII chars.

Thanks for you help

Greg


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

Date: 18 Mar 2004 09:22:40 -0800
From: djbitchpimp@snowboard.com (Greg)
Subject: Re: stripping out ASCII chars using regexp?
Message-Id: <7e312ede.0403180922.78f06602@posting.google.com>

OK I'm an idiot.

I had:

$_ = $word ;

s/\240//g ;
s/[\200-\377]//g ;
tr/\177-\377//d ;
s/\&#65533//g ;

but i never had the line:

$word = $_ ;

Newbie mistake!

Sorry for the phantom bug guys, but thanks for all the help.

Greg


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

Date: Thu, 18 Mar 2004 17:33:41 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Variable interpolation in regular expressions
Message-Id: <4059d5f0.568325669@news.erols.com>

Dave <dave@nospam.com> wrote:

: I realize that this "gotcha" has been discussed here ad nauseum 
: (verified by Google), but I don't understand why the Camel book says: 
: "Since patterns are processed as double-quoted strings, the normal 
: double-quoted interpolations will work."  (Page 60 of Programming Perl, 
: 2nd Ed.)
: 
: Wouldn't it be more appropriate to say that they're subject to "double 
: interpolation," for lack of better words?

How about:  They're subject to variable interpolation like double-quoted
strings, then they're subject to metacharacter translation by the regex
compiler.

: In a double quoted string, a 
: scalar variable is substituted by its value; however, that value is not 
: subject to interpolation itself.  In a regular expression, the pattern 
: is also substituted by its corresponding value, but the resulting value 
: is *also* subject to interpolation.
: 
: Example:
: my $string1 = 'A\n single\n quoted\n string\n';
: print "\$string1 prints \"A\\n single\\n quoted\\n string\\n\" as one 
: would expect: $string1\n";
: $_ = $string1;
: print "This won't print\n" if m/$string1/;
: print "But this will\n" if m/\Q$string1/;

More simply demonstrated:

    my $s = '\n';
    print "unexpected match" if '
    ' =~ $s;
 
: So, how is it that "patterns are processed as double-quoted strings?" 
: I'm not trying to split hairs; I just want to understand why my logic 
: does not seem to agree with that statement, with the hope of avoiding 
: needless traps further down the road.

It helps if you distinguish between the variable interpolation step and the
regex compilation step.  '\n' in a double-quotish string context is not
exactly the same thing as '\n' in a regex.

    for(
        "\n", # The double-quote mechanism translates that into a newline.
        '\n', # That one becomes the regex compiler's problem.
    ) {
        my $rx = qr/$_/;
        print "newline character is matched by: $rx\n"
          if "\n" =~ $rx;
    }

It's a subtle difference that can easily burn you.  I don't see how Perl
could DWIM that and similar cases without reflexively meta-quoting all
interpolated variables, which would severely limit the utility of variable
interpolation in a regex.



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

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 6274
***************************************


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