[14013] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1423 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 18 18:36:22 1999

Date: Thu, 18 Nov 1999 15:36:05 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <942968164-v9-i1423@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 18 Nov 1999     Volume: 9 Number: 1423

Today's topics:
        problem with DBM delete <chris@datassociates.com>
    Re: problem with DBM delete <moseley@best.com>
    Re: problem with DBM delete <moseley@best.com>
    Re: problem with DBM delete <chris@datassociates.com>
        Q: DBI.pm (odd warnings) erik_lembke@my-deja.com
    Re: Q: DBI.pm (odd warnings) <jeff@vpservices.com>
    Re: Q: DBI.pm (odd warnings) <rootbeer@redcat.com>
    Re: reading html files <nigell.boulton@rade.net>
    Re: reading html files <gellyfish@gellyfish.com>
        regular expression help (Alexis PONCET)
    Re: regular expression help <gellyfish@gellyfish.com>
    Re: removing unwanted parts of a string... <lr@hpl.hp.com>
    Re: removing unwanted parts of a string... schablone@my-deja.com
    Re: Rephrase lee.lindley@bigfoot.com
    Re: Save As box... printing an image to the screen" <rootbeer@redcat.com>
    Re: Save As box... printing an image to the screen" <rootbeer@redcat.com>
    Re: Serious memory leak in MacPERL? (Anno Siegel)
    Re: Serious memory leak in MacPERL? (Tom Sheppard)
        Setting Environment variables from a perl script ps123@my-deja.com
    Re: Setting Environment variables from a perl script <arthur.haas@westgeo.com>
        Several Perl questions related to speed and memory use <jacks@pobox.com>
    Re: Several Perl questions related to speed and memory  <rootbeer@redcat.com>
    Re: Several Perl questions related to speed and memory  <lr@hpl.hp.com>
    Re: Several Perl questions related to speed and memory  (Kragen Sitaker)
    Re: Several Perl questions related to speed and memory  <rootbeer@redcat.com>
    Re: signature question (was Re: Help with Stoopid Nutsc (Csaba Raduly)
    Re: signature question (was Re: Help with Stoopid Nutsc <jmn.ac.delete@abanet.it>
    Re: Split a input file with perl <gellyfish@gellyfish.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 18 Nov 1999 16:27:00 GMT
From: Chris Stigas <chris@datassociates.com>
Subject: problem with DBM delete
Message-Id: <383428D2.40B87CFF@datassociates.com>

Hello,

I am having a problem with this small piece of code:

 while (($key, $value) = each(%MAILDB)) {
        if($MAILDB{$key} eq 0){
             delete $MAILDB{$key};
        }
    }

For some reason, once it iterates through the first loop and finds a
value of 0, it deletes it but also exits the whole loops, and doesn't
proceed through the "while" loop.  Does anyone have any ideas on how to
resolve this?

Regards,
Chris



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

Date: Thu, 18 Nov 1999 12:28:08 -0800
From: Bill Moseley <moseley@best.com>
Subject: Re: problem with DBM delete
Message-Id: <MPG.129e0134b09d6f2898988f@nntp1.ba.best.com>

Kragen Sitaker (kragen@dnaco.net) seems to say...
> In article <38343E17.90732267@datassociates.com>,
> Chris Stigas  <chris@datassociates.com> wrote:
> >yes.  The compare works.. however I think that when the hash entry is
> >deleted, it somehow, "messes up" the continuation of the loop.
> 
> That's right.  Don't insert into or delete from a hash while you're
> iterating over it -- it doesn't work.  perldoc -f each will tell you
> more.

I can see this being confusing:

perldoc -f each
[...]
 If you add or delete elements of a hash while
 you're iterating over it, you may get entries skipped or
 duplicated, so don't.


Programming Perl 2nd Edition p159

each
[...]
 You must not add elements to the hash while iterating over it,
 although you are permitted to use delete.


-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: Thu, 18 Nov 1999 09:29:46 -0800
From: Bill Moseley <moseley@best.com>
Subject: Re: problem with DBM delete
Message-Id: <MPG.129dd768f379ada698988b@nntp1.ba.best.com>

Chris Stigas (chris@datassociates.com) seems to say...
> Hello,
> 
> I am having a problem with this small piece of code:
> 
>  while (($key, $value) = each(%MAILDB)) {
>         if($MAILDB{$key} eq 0){
                           ^^
You want to compare numbers?

-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: Thu, 18 Nov 1999 17:57:45 GMT
From: Chris Stigas <chris@datassociates.com>
Subject: Re: problem with DBM delete
Message-Id: <38343E17.90732267@datassociates.com>

yes.  The compare works.. however I think that when the hash entry is
deleted, it somehow, "messes up" the continuation of the loop.  Maybe
somehow throwing off the 'each(%MAILDB)' command.  Any ideas or
thoughts?  I have only been programming with perl for a few days, so I'm
not too experienced with Perl.

Bill Moseley wrote:

> Chris Stigas (chris@datassociates.com) seems to say...
> > Hello,
> >
> > I am having a problem with this small piece of code:
> >
> >  while (($key, $value) = each(%MAILDB)) {
> >         if($MAILDB{$key} eq 0){
>                            ^^
> You want to compare numbers?
>
> --
> Bill Moseley mailto:moseley@best.com
> pls note the one line sig, not counting this one.



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

Date: Thu, 18 Nov 1999 10:50:24 GMT
From: erik_lembke@my-deja.com
Subject: Q: DBI.pm (odd warnings)
Message-Id: <810llg$g5d$1@nnrp1.deja.com>

Hello,

I got odd warnings when I use the DBI Interface in perl.
They look like this:
Use of uninitialized value at (eval 21) line 18.

How can I evalute such a warning?
(my line 18 is empty)

IMHO these warnings are created if i generate invalid sql statements.

cheers Erik



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 18 Nov 1999 20:51:15 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Q: DBI.pm (odd warnings)
Message-Id: <38346679.3D77AFCD@vpservices.com>

Scott Lanning wrote:
> 
> erik_lembke@my-deja.com writes:
> > I got odd warnings when I use the DBI Interface in perl.
> > They look like this:
> > Use of uninitialized value at (eval 21) line 18.
> >
> > (my line 18 is empty)
> 
> Or so you claim! Hmmph!

And why shouldn't we believe that claim?  The error message refers to
line 18 of the eval, not line 18 of the code.

-- 
Jeff


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

Date: Thu, 18 Nov 1999 10:11:00 -0800
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Q: DBI.pm (odd warnings)
Message-Id: <Pine.GSO.4.10.9911181009060.16575-100000@user2.teleport.com>

On Thu, 18 Nov 1999 erik_lembke@my-deja.com wrote:

> Use of uninitialized value at (eval 21) line 18.
> 
> How can I evalute such a warning?
> (my line 18 is empty)

It's not your line 18, but the 18th line of the 21st eval STRING. Alas,
there's no great way to identify which one is the 21st string without
doing something like stepping through your program in the debugger.

> IMHO these warnings are created if i generate invalid sql statements.

<doctor>Well, stop doing that.</doctor>

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 18 Nov 1999 12:36:45 -0000
From: "Nigell Boulton" <nigell.boulton@rade.net>
Subject: Re: reading html files
Message-Id: <3833e802.0@news.netdirect.net.uk>

How do I format the results in HTML?




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

Date: 18 Nov 1999 12:53:07 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: reading html files
Message-Id: <3833f6b3_1@newsread3.dircon.co.uk>

Nigell Boulton <nigell.boulton@rade.net> wrote:
> How do I format the results in HTML?

You use 'print'  -  did I not say :

> but you would want to print the stuff returned from get_articles() in your
> own way.



/J\
-- 
"I'm not Carol Vorderman - you wouldn't see me getting drunk in a kebab
shop" - Lily Savage


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

Date: Thu, 18 Nov 1999 16:36:11 GMT
From: poncet@webevent.org (Alexis PONCET)
Subject: regular expression help
Message-Id: <poncet-1811991741130001@10.0.0.103>

Hi !

I'm posting here the question because Perl programmer are better than PHP
programmer in regular expression (well I think so ;-))

Actually I'm building a small program that could allow the user to know
the title, the keywords and the description of an HTML page.
I don't know how to built a optimized regular expression to parse the
string I get from an fgets after a fsockopen.
I need to get back in several variables the value of the title, keywords
and description (both in meta tag).
Do you think it is possible ?

Thank you for your help.
Here is my source code in PHP.

Alex

<?
$serveur = "www.php.net";
$fp = fsockopen("$serveur", 80);
if($fp == 0);
echo "$fp<br>\n";
else;
fputs($fp,"GET  / HTTP/1.0\n\n");
while(!feof($fp));
$string = fgets($fp,128);
/********
I don't know what to put here
*********/
if (ereg("<title", $string, $reg));
echo "***$regs[1]";
endif;
endwhile;

fclose($fp);
endif;
>


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

Date: 18 Nov 1999 16:49:46 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: regular expression help
Message-Id: <38342e2a_1@newsread3.dircon.co.uk>

Alexis PONCET <poncet@webevent.org> wrote:
> Hi !
> 
> I'm posting here the question because Perl programmer are better than PHP
> programmer in regular expression (well I think so ;-))
> 

But its still a PHP question which should be asked in a PHP group. 

/J\
-- 
"The chef's salty balls have dropped" - Christopher Price, BBC NEWS 24


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

Date: Thu, 18 Nov 1999 13:16:14 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: removing unwanted parts of a string...
Message-Id: <MPG.129e0c7bac74a3ed98a232@nntp.hpl.hp.com>

In article <8110pi$nnk$1@nnrp1.deja.com> on Thu, 18 Nov 1999 14:00:20 
GMT, schablone@my-deja.com <schablone@my-deja.com> says...
> In article <MPG.129cc553359a5ae998a226@nntp.hpl.hp.com>,
>   Larry Rosler <lr@hpl.hp.com> wrote:

 ...

> > All this is described in perlop and perlre, of course.  Read, read,
> > read...

 ...

> Anyway, enough of this rambling, must get back to my plans for world
> domination.
> 
> Many thanks for the reply, I really appreciate all the advice
> put out on comp.lang.perl.misc and learn a lot just by lurking.
> Fraid I can't really reciprocate right now, but once I've achieved
> world power the post of Lord High Perl Monger is yours for the asking.

Sounds good to me.  I'll (try to) hold you to it, but once you've 
achieved world power I don't know what power I would have.  :-)

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 18 Nov 1999 14:00:20 GMT
From: schablone@my-deja.com
Subject: Re: removing unwanted parts of a string...
Message-Id: <8110pi$nnk$1@nnrp1.deja.com>

In article <MPG.129cc553359a5ae998a226@nntp.hpl.hp.com>,
  Larry Rosler <lr@hpl.hp.com> wrote:
> In article <80v63h$f0c$1@nnrp1.deja.com> on Wed, 17 Nov 1999 21:18:46
> GMT, schablone@my-deja.com <schablone@my-deja.com> says...
>
> ...
>
> > With the following code I wish to remove all the contents from a
given
> > variable except
> > for a word beginning with, for example, "&", using a regular
expression.
> > Is there a way
> > of doing this in one line? The only way I have come up with is to
> > perform a regular
> > expression a la $mytext =~ m/&\w* / then  assign the resulting $& to
> > $mytext.
>
> Please fix your newsreader's line wrapping so this doesn't happen.

My abject apologies, I was gratuitously cutting and pasting
and some CRs slipped in. I will horsewhip my computer so
it doesn't do it again.

> > Viz:
> >
> > #!/usr/bin/perl -w
> >
> > use strict;
>
> Two style points for those!

Thankyou :-)
Can I cash them in for anything?
Seriously some of us clueless newbies do lurk around before
posting to get an idea of what's de rigeur.

> > my $message = "Vote for Schablonski or have your &thingy cut off!";
> Minus one style point for double-quotes instead of single-quotes when
> there is no interpolation.

Oops, missed that one. Point noted. Still plus one point though.

> > $message =~ m/&\w* /;
> > $message = $&;
> >
> > # do whatever else I want to do with &thingy..
> >
> > exit(0);
> >
> >
> > Is there another way?
>
> Are you unaware of the Perl motto TMTOWTDI?

Yup. Even come up with a modification, TMBMTOWTDT
(There Must Be More Than One Way To Do This)
or
TMBABWTDTTTOICUWAHRATKFTLTH
(There Must Be A Better Way To Do This Than The One I've Come Up
With After Hacking Randomly At The Keyboard For The Last Two Hours)

> Of course; there are
> several other ways.  Here is one:
>
>     $message =~ s/.*?(&\w+ ).*/$1/s;
>
> If you don't want the '&' and space, move the parentheses
appropriately.
> If there is more than one such match and you want the last one rather
> than the first, remove the '?'.

Strangely enough I subsequently switched my brain on and came up
with something similar (although naturally not as good):

       $message =~ s/.*(&\w* ).*/$1/;

> All this is described in perlop and perlre, of course.  Read, read,
> read...

I know, that's what everybody says. Unfortunately sometimes the more I
read the more bug-eyed I get and I can never find quite the answer to
what I'm looking for. I'd love to be able to ask an offline, real
world colleague but I'm stuck with a bunch of people who call themselves
"HTML programmers". Talk about the one-eyed man in the land of the
blind...

Anyway, enough of this rambling, must get back to my plans for world
domination.

Many thanks for the reply, I really appreciate all the advice
put out on comp.lang.perl.misc and learn a lot just by lurking.
Fraid I can't really reciprocate right now, but once I've achieved
world power the post of Lord High Perl Monger is yours for the asking.

Schablonsk


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 18 Nov 1999 20:05:25 GMT
From: lee.lindley@bigfoot.com
Subject: Re: Rephrase
Message-Id: <811m65$kbb$1@rguxd.viasystems.com>

Kragen Sitaker <kragen@dnaco.net> wrote:
:>In article <jtropp-1711992148530001@dial-83-8.ots.utexas.edu>,
:>Joel A. Tropp <jtropp@ticam.utexas.edu> wrote:
:>>Why doesn't this work right?
:>>
:>>$files{ $cat } = "feh";             # Black Magic
:>>
:>>open( $files{ $cat }, ">$fname" );

:>Because filehandles and typeglobs are evil.  One of these days I'll get
:>up the courage to delve into the stinking pit of human error and
:>depravity that is filehandles, and maybe I'll even like it; until then,
:>I use IO::Handle and put blocks around expressions to fetch filehandles
:>from hashes.

Oh come now Kragen, they aren't that bad.  

perldoc -q filehandles

presents some nice little examples of how to localize the typeglobs
and store them in an array or hash.  You can use the typglob of the 
filehandle almost as easily as the bareword.  

{
	local *feh;	# Block and local not required, but advisable
	$files{$cat} = *feh;
}
my $fh = $files{$cat};# Required: open() won't take hash or array entry
open ($fh, ">$fname") or die "Could not open $fname: $!";


-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: Thu, 18 Nov 1999 13:08:46 -0800
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Save As box... printing an image to the screen"
Message-Id: <Pine.GSO.4.10.9911181307450.16575-100000@user2.teleport.com>

On 18 Nov 1999, Frosty wrote:

> Newsgroups: comp.lang.perl.misc, alt.comp.perlcgi.freelance

> Actually, for this NG, the question should be "who can I hire to fix this?"

No, but you're close. That question is for a newsgroup with 'jobs' in the
name. There is no question for this newsgroup. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 18 Nov 1999 09:07:32 -0800
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Save As box... printing an image to the screen"
Message-Id: <Pine.GSO.4.10.9911180906540.16575-100000@user2.teleport.com>

On Thu, 18 Nov 1999, Slim wrote:

> when I choose save as to save the image the name of the image will be
> the script name... is there a way to make it say the real name of the
> image in the save as box"

Sounds as if you want to ask a browser to do something. Perhaps you should
search for the docs, FAQs, and newsgroups about browsers and how to talk
to them. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 18 Nov 1999 12:23:26 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Serious memory leak in MacPERL?
Message-Id: <810r3u$49g$1@lublin.zrz.tu-berlin.de>

Tom Sheppard <sheppard@magma.ca> wrote in comp.lang.perl.misc:
>In article <spamfree-1311991515360001@d5.metropolis.net.au>,

[...]

>Even the "undef" takes a long time so I assume the hash is composed of
>many entries linked together which have to be individually freed. I don't

Sounds likely.

>know if it's possible to preallocate memory in one chunk for a hash and
>then free that quickly and completely.

You can preallocate hash space by assigning the estimated number of
keys to the keys() function:

  keys( %hash) = 1000;

assigns 1024 buckets (the next power of two) to %hash.

The way Perl does this is at the same time over-intuitive (assigning
to keys()) and counter-intuitive (assigning a number to something that
normally is a list), so much so that I find myself looking it up
each time I need to know.

Anno


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

Date: Thu, 18 Nov 1999 17:25:23 GMT
From: sheppard@magma.ca (Tom Sheppard)
Subject: Re: Serious memory leak in MacPERL?
Message-Id: <sheppard-1811991225230001@192.168.0.1>

In article <810r3u$49g$1@lublin.zrz.tu-berlin.de>,
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:

> You can preallocate hash space by assigning the estimated number of
> keys to the keys() function:
> 
>   keys( %hash) = 1000;
> 
> assigns 1024 buckets (the next power of two) to %hash.

Thanks. I'll try that and see if it helps. I should be doing another build
of the database this weekend.


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

Date: Thu, 18 Nov 1999 22:07:22 GMT
From: ps123@my-deja.com
Subject: Setting Environment variables from a perl script
Message-Id: <811tao$f3g$1@nnrp1.deja.com>

Hi,

I would like to set a user-defined environment variable from a
perl script, and export it to the parent shell (I am converting a shell
script to a perl script). Can someone tell me as to how I can achieve
it?

I have tried the following and they have not worked:

system(export ENV_VAR=VALUE);  -- perl aborts with the message that it
                                  cannot find the object 'export'
$ENV{ENV_VAR}=VALUE; -- the value is set, but not visible in the parent
                        shell

Thanks
PN


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 18 Nov 1999 16:32:33 -0600
From: Art Haas <arthur.haas@westgeo.com>
Subject: Re: Setting Environment variables from a perl script
Message-Id: <lrvh6zl9by.fsf@yoda.wg.waii.com>

ps123@my-deja.com writes:

> Hi,
> 
> I would like to set a user-defined environment variable from a
> perl script, and export it to the parent shell (I am converting a shell
> script to a perl script). Can someone tell me as to how I can achieve
> it?
> 
> I have tried the following and they have not worked:
> 
> system(export ENV_VAR=VALUE);  -- perl aborts with the message that it
>                                   cannot find the object 'export'
> $ENV{ENV_VAR}=VALUE; -- the value is set, but not visible in the parent
>                         shell
> 

Short answer - you can't do what you're trying to do. See perlfaq8.

-- 
###############################
# Art Haas
# (713) 689-2417
###############################


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

Date: Thu, 18 Nov 1999 10:16:36 -0500
From: "HIS Newsgroups" <jacks@pobox.com>
Subject: Several Perl questions related to speed and memory use
Message-Id: <38341855.0@news4.his.com>

[I had earlier posted this to comp.lang.perl but I see it's not read as much
as this one; sorry for the multiple postings.]

I am developing a Perl script (5.00503 on NT) that processes many lines of
text. I am looking into ways to speed it up. Unfortunately, because of
company regulations, I cannot post all of my script here.

For one pattern match, I would like to find out if there is a faster way to
do this. In the code fragment below, the $csCookie is composed of a number
of keyword=value pairs, spearated by semicolons.The XYZZY is composed of
upper- and lower-case letters and/or digits. Is there a faster way to do
this pattern match? I could possibly use the \w character, and ignore the
fact that it would allow the underscore character to be in the string also,
if this was significantly faster than the pattern used below. Or, what if I
used /XYZZY=(\w*/ and, if that succeeded, then look for the underscore
- would that be faster than what I am using below?

if ($csCookie =~ m/XYZZY=([A-Za-z0-9]+)/) {
    $ValidStrings ++;
    return $1;
}


When I run my script on 30 files (averaging around 125,000 KB each), the
rate at which the script processes each file decreases as it progresses
through the 30 files. The script uses anonymous arrays, hashs, etc. But, I
am fairly certain I have gotten all the "memory leaks" out of it. So, I'm
not sure if memory is the problem; what are some of the common reasons for a
decrease in speed as Perl runs?

If I wanted to check to make sure I was undef'ing all my references and
deleting hash keys no longer used, is there a way to dump or look at all the
memory my script has allocated and see the reference counts?

Thanks for your help,
Jack Stansbury
jacks@pobox.com





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

Date: Thu, 18 Nov 1999 13:26:13 -0800
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Several Perl questions related to speed and memory use
Message-Id: <Pine.GSO.4.10.9911181325110.16575-100000@user2.teleport.com>

On Thu, 18 Nov 1999, Ala Qumsieh wrote:

> Since you are using a recent version of Perl, look into using the qr//
> operator to compile your regular expression first.

I don't think that will make any difference, since the pattern in question
should be compiled just once in any case. Unless I'm mistaken about what
you're talking about. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 18 Nov 1999 14:51:51 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Several Perl questions related to speed and memory use
Message-Id: <MPG.129e22e3e8b5673398a233@nntp.hpl.hp.com>

In article <x3yln7vzmyu.fsf@tigre.matrox.com> on Thu, 18 Nov 1999 
13:14:18 -0500, Ala Qumsieh <aqumsieh@matrox.com> says...
> 
> "HIS Newsgroups" <jacks@pobox.com> writes:

 ...

> > For one pattern match, I would like to find out if there is a faster way to
> > do this. In the code fragment below, the $csCookie is composed of a number
> > of keyword=value pairs, spearated by semicolons.The XYZZY is composed of
> > upper- and lower-case letters and/or digits. Is there a faster way to do
> > this pattern match? I could possibly use the \w character, and ignore the
> > fact that it would allow the underscore character to be in the string also,
> > if this was significantly faster than the pattern used below. Or, what if I
> > used /XYZZY=(\w*/ and, if that succeeded, then look for the underscore
> > - would that be faster than what I am using below?
> 
> I doubt it. I highly doubt that this is the bottle neck in your
> program. You could probably do something like:
> 
> 	/XYZZY=([^_\s]+)/

That will match against all kinds of unwanted punctuation characters.  
You need this:

  	/XYZZY=([^_\W]+)/

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 18 Nov 1999 19:20:03 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Several Perl questions related to speed and memory use
Message-Id: <DjYY3.25893$YI2.1149441@typ11.nn.bcandid.com>

In article <38341855.0@news4.his.com>, HIS Newsgroups <jacks@pobox.com> wrote:
>[I had earlier posted this to comp.lang.perl but I see it's not read as much
>as this one; sorry for the multiple postings.]

That newsgroup was deleted in 1995.

>For one pattern match, I would like to find out if there is a faster way to
>do this. In the code fragment below, the $csCookie is composed of a number
>of keyword=value pairs, spearated by semicolons.The XYZZY is composed of
>upper- and lower-case letters and/or digits. Is there a faster way to do
>this pattern match? I could possibly use the \w character, and ignore the
>fact that it would allow the underscore character to be in the string also,
>if this was significantly faster than the pattern used below. Or, what if I
>used /XYZZY=(\w*/ and, if that succeeded, then look for the underscore
>- would that be faster than what I am using below?

The new regex would probably be equivalently fast; perldoc Benchmark if
you want to find out.

>if ($csCookie =~ m/XYZZY=([A-Za-z0-9]+)/) {
(I don't have an answer to your other questions.)

-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 18 Nov 1999 11:18:21 -0800
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Several Perl questions related to speed and memory use
Message-Id: <Pine.GSO.4.10.9911181044520.16575-100000@user2.teleport.com>

On Thu, 18 Nov 1999, HIS Newsgroups wrote:

> Unfortunately, because of company regulations, I cannot post all of my
> script here.

That's okay; we don't want to see all of your script. But if you want us
to help with part of it, we'll need to see part. (Of course, you could let
us help with a similar script....)

> Is there a faster way to do this pattern match?

> if ($csCookie =~ m/XYZZY=([A-Za-z0-9]+)/) {

Probably not much faster, if at all. But if you really want to know
whether one approach is faster than another, use Benchmark.

> When I run my script on 30 files (averaging around 125,000 KB each),
> the rate at which the script processes each file decreases as it
> progresses through the 30 files.

You're probably doing something wrong. See whether you can write a small
self-contained program which we can run to see the same behavior. It
should be fewer than a dozen lines, if possible, and it shouldn't use
external data.

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 18 Nov 1999 10:11:43 GMT
From: csaba_r@my-deja.com (Csaba Raduly)
Subject: Re: signature question (was Re: Help with Stoopid Nutscrape (Netscape))
Message-Id: <8E826104Cquuxi@10.1.2.158>

arvind@mail.ece.umn.edu wrote in <80urpu$gp4$1@news1.tc.umn.edu>:

>In <slrn82n5gq.lmh.abigail@alexandra.delanet.com>, Abigail
><abigail@delanet.com> wrote: 
>> Andrew Broadley (expoinfo@globalexpos.co.nz) wrote on MMCCLXIV
>> September MCMXCIII in <URL:news:382B624E.23C018E6@globalexpos.co.nz>:
>
>> Abigail
>
>okay, so this signature I didn't get:
>perl -wle '$, = " "; print grep {(1 x $_) !~ /^(11+)\1+$/} 2 .. shift'
>

This seems to be the extension of anotherAbigail sig which
just said "prime" or gave the smallest divisor (or all?)
of a number.

Csaba

-- 
-----BEGIN GEEK CODE BLOCK----- 
Version 3.1
GCS/MU d- s:- a30 C++$ UL+ P+>+++ L++ E- W+ N++ o? K? w++>$ O++$ M-
V- PS PE Y PGP- t+ 5 X++ R* tv++ b++ DI+++ D++ G- e+++ h-- r-- !y+
-----END GEEK CODE BLOCK----- 

Csaba Raduly,    Software Developer (OS/2),    Sophos Anti-Virus
mailto:csaba.raduly@sophos.com            http://www.sophos.com/
US Support +1 888 SOPHOS 9            UK Support +44 1235 559933
Life is complex, with real and imaginary parts.


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

Date: Thu, 18 Nov 1999 13:55:55 +0100
From: John McNamara <jmn.ac.delete@abanet.it>
Subject: Re: signature question (was Re: Help with Stoopid Nutscrape (Netscape))
Message-Id: <=vYzOCo=h4C4KzBxKaXHLLf5olLP@4ax.com>

On 17 Nov 1999 19:57:13 GMT, arvind@mail.ece.umn.edu wrote:

>I'll have to sit down with the docs to figure out how this
>works (grep and reg. exp. to generate primes, this should be interesting)


The regex (and Abagail) are discussed in Chapter 10 of Andrew L.
Johnson's Book. In Section 10.6.1 "Prime number regex".

Try  http://www.manning.com/Johnson/


John McNamara
-- 


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

Date: 18 Nov 1999 09:49:05 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Split a input file with perl
Message-Id: <3833cb91_2@newsread3.dircon.co.uk>

Huy Vu <huyv@usa.net> wrote:
> Hi all,
> 
> I have a file with a format as below:
> 
> ^R
>                            AAAAAA   BBBBBbb  CCCCCCCc
> 
> PARAGRAPH   #1
> 
> ^O1234     Testing        54.0

I'm not quite clear what you mean - do you mean that you want to save all
the lines that begin with a a ctrl-O,  I think your data might have got
garbled up in usenet somewhere 

/J\
-- 
"Report accuses Royal Opera House of 'arrogance and elitism'. Report
further alleges that Pope is Catholic. Report further claims that bears
may well indeed defecate in the woods" - Private Eye


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

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


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