[9431] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3023 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 30 14:18:22 1998

Date: Tue, 30 Jun 98 10:57:34 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 30 Jun 1998     Volume: 8 Number: 3023

Today's topics:
        some questions about array refs & efficiency <sfarrell@farrell.org>
        some questions about array refs & efficiency (Sean McAfee)
    Re: some questions about array refs & efficiency <rick.delaney@shaw.wave.ca>
    Re: some questions about array refs & efficiency <rootbeer@teleport.com>
    Re: some questions about array refs & efficiency (Sean McAfee)
    Re: some questions about array refs & efficiency <rootbeer@teleport.com>
    Re: some questions about array refs & efficiency (M.J.T. Guy)
    Re: some questions about array refs & efficiency (Ronald J Kimball)
        Sorting values usings arrays <Pap22@erols.com>
    Re: Sorting values usings arrays (Larry Rosler)
    Re: Sorting values usings arrays <Pap22@erols.com>
    Re: Sorting values usings arrays (Larry Rosler)
        Speed of embeding PERL into C++ <shawn@thememedia.com>
    Re: Spider programms in PERL (John Armsby)
        SQL Statement Troubles (sweston)
    Re: SQL Statement Troubles <simon@getreal.demon.co.uk>
        Statistics for comp.lang.perl.misc <gbacon@cs.uah.edu>
        string replacement <mftsang@cse.cuhk.edu.hk>
    Re: string replacement <quednauf@nortel.co.uk>
    Re: string replacement <rra@stanford.edu>
    Re: string replacement (Larry Rosler)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sun, 28 Jun 1998 10:16:59 GMT
From: stephen farrell <sfarrell@farrell.org>
Subject: some questions about array refs & efficiency
Message-Id: <87ra09q19g.fsf@couatl.uchicago.edu>



how do i cleanly merge two array refs without copying?

i have $array_ref_a and $array_ref_b.  I want $new_array_ref which
contains the contents of $array_ref_a and $array_ref_b.

	$new_array_ref = [ @$array_ref_a, @$array_ref_b ];

or

	push @$array_ref_a, @$array_ref_b;

causes a copy, which is not what I want (plus it's inefficient).  it's
my intuition that this is impossible, since array 'a' is at one memory
location and array 'b' is at another.  the new array wants to point to
one continuous array with the contents of 'a' and 'b', but the memory
doesn't look like that--so a copy needs to be made to accomplish this
continuous memory picture.

if i'm right, then what does one do when one has some huge arrays
like:

	$words_in_the_old_testament_array_ref;
	$words_in_the_new_testament_array_ref;

and you want a new array with all the elements in both arrays?  is
there any way to avoid the copy?




and on a related note, does dereferencing in a scalar context cause a
copy?  Should I feel comfortable doing:

	my $num_words = scalar(@$words_in_the_dictionary);


tia

--sf


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

Date: Mon, 29 Jun 1998 00:00:36 GMT
From: mcafee@qix.rs.itd.umich.edu (Sean McAfee)
Subject: some questions about array refs & efficiency
Message-Id: <EOAl1.1502$24.9064456@news.itd.umich.edu>

In article <87ra09q19g.fsf@couatl.uchicago.edu>,
stephen farrell  <sfarrell@farrell.org> wrote:
>how do i cleanly merge two array refs without copying?

>i have $array_ref_a and $array_ref_b.  I want $new_array_ref which
>contains the contents of $array_ref_a and $array_ref_b.
>	$new_array_ref = [ @$array_ref_a, @$array_ref_b ];
>or
>	push @$array_ref_a, @$array_ref_b;
>causes a copy, which is not what I want (plus it's inefficient).  it's
>my intuition that this is impossible, since array 'a' is at one memory
>location and array 'b' is at another.  the new array wants to point to
>one continuous array with the contents of 'a' and 'b', but the memory
>doesn't look like that--so a copy needs to be made to accomplish this
>continuous memory picture.

Internally, a Perl array is an array of pointers.  One *could* make a copy
of only the pointers, but that would generally result in undesirable
behavior, eg:

@a = (1, 2);  @b = (3, 4);
@c = (@a, @b);	# copying pointers only
$c[2]++;
print $b[0];	# prints "4"

The corrent behavior is to clone all of the scalar objects pointed to by
the elements of both arrays.

>if i'm right, then what does one do when one has some huge arrays
>like:
>	$words_in_the_old_testament_array_ref;
>	$words_in_the_new_testament_array_ref;
>and you want a new array with all the elements in both arrays?  is
>there any way to avoid the copy?

A Perl module to perform such a copy is pretty simple, if you're familiar
with the internal Perl API:

AV *array1, *array2;
/* set array1 and array2 to refer to the two arrays to be concatenated */
AV *result = newAV();
I32 i, len1, len2;
av_extend(result, (len1 = av_len(array1)) + (len2 = av_len(array2)) + 2);
    /* ^^^ Assuming no fiddling has been done with $[... */
for (i = 0; i <= len1; i++)
    av_push(result, SvREFCNT_inc(*av_fetch(array1, i, 0)));
for (i = 0; i <= len2; i++)
    av_push(result, SvREFCNT_inc(*av_fetch(array2, i, 0)));

Afterwards, the strange behavior described above will be evident, but the
speed increase may be worth it to you if the arrays are very large.

(Embedding this routine into an XS call is left as an exercise for the
reader.)

-- 
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu



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

Date: Sun, 28 Jun 1998 18:50:57 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
To: stephen farrell <sfarrell@farrell.org>
Subject: Re: some questions about array refs & efficiency
Message-Id: <35968429.9166529D@shaw.wave.ca>

stephen farrell wrote:
> 
> i have $array_ref_a and $array_ref_b.  I want $new_array_ref which
> contains the contents of $array_ref_a and $array_ref_b.
> 
>         $new_array_ref = [ @$array_ref_a, @$array_ref_b ];
> ... 
> causes a copy, which is not what I want (plus it's inefficient).  it's
> my intuition that this is impossible, since array 'a' is at one memory
> location and array 'b' is at another.
> ...
> if i'm right, then what does one do when one has some huge arrays
> like:
> 
>         $words_in_the_old_testament_array_ref;
>         $words_in_the_new_testament_array_ref;
> 
> and you want a new array with all the elements in both arrays?  is
> there any way to avoid the copy?
>

Let me just preface this by saying that I don't know anything about the
internals of perl so anything I say here is just conjecture.  Hopefully
someone will correct me if I'm wrong about anything.  

To avoid the copy, consider keping the two arrays separate and just
refer to both in a list context.

foreach (@$old_testament_words, @$new_testament_words) {
	s/God/Larry/;
}

I don't think foreach would make copies since it allows the original
values to be changed.  I don't see how you can avoid a copy if you want
to create a new variable.
 
> and on a related note, does dereferencing in a scalar context cause a
> copy?  Should I feel comfortable doing:
> 
>         my $num_words = scalar(@$words_in_the_dictionary);

I think that perl is too smart to make a copy here.  After all it
doesn't iterate through all the keys in this scalar context:

	$numkeys = keys %hash; 

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Mon, 29 Jun 1998 04:15:44 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: some questions about array refs & efficiency
Message-Id: <Pine.GSO.3.96.980628211411.21917C-100000@user2.teleport.com>

On Mon, 29 Jun 1998, Sean McAfee wrote:

> @a = (1, 2);  @b = (3, 4);
> @c = (@a, @b);	# copying pointers only
> $c[2]++;
> print $b[0];	# prints "4"

That turns out not to be the case. Cheers!

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



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

Date: Mon, 29 Jun 1998 05:03:45 GMT
From: mcafee@choplifter.rs.itd.umich.edu (Sean McAfee)
Subject: Re: some questions about array refs & efficiency
Message-Id: <ReFl1.1552$24.9229019@news.itd.umich.edu>

In article <Pine.GSO.3.96.980628211411.21917C-100000@user2.teleport.com>,
Tom Phoenix  <rootbeer@teleport.com> wrote:
>On Mon, 29 Jun 1998, Sean McAfee wrote:
>> @a = (1, 2);  @b = (3, 4);
>> @c = (@a, @b);	# copying pointers only
>> $c[2]++;
>> print $b[0];	# prints "4"

>That turns out not to be the case. Cheers!

You do understand that I was showing what *would* happen if Perl only
copied SV *'s instead of cloning SV's, right?

Anyway, here's proof:

/* after perl_alloc, perl_construct, perl_parse (args = "", "-e", "0"),
   and perl_run... */

AV *a, *b, *c;

perl_eval_sv(newSVpv("@a = (1,2); @b = (3,4);", 0), 0);
a = perl_get_av("a", FALSE);
b = perl_get_av("b", FALSE);
c = perl_get_av("c", TRUE);
av_push(c, SvREFCNT_inc(*av_fetch(a, 0, 0)));
av_push(c, SvREFCNT_inc(*av_fetch(a, 1, 0)));
av_push(c, SvREFCNT_inc(*av_fetch(b, 0, 0)));
av_push(c, SvREFCNT_inc(*av_fetch(b, 1, 0)));
perl_eval_sv(newSVpv("$c[2]++;", 0), 0);
printf("%d\n", SvIV(*av_fetch(b, 0, 0)));

 ...When I ran this, "4" was printed.  This would seem to conclusively
bear out my hypothesis.  If I'm still missing something, I've love to know
about it, preferably with an explanation.

-- 
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu


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

Date: Mon, 29 Jun 1998 05:50:08 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: some questions about array refs & efficiency
Message-Id: <Pine.GSO.3.96.980628224936.21917I-100000@user2.teleport.com>

On Mon, 29 Jun 1998, Sean McAfee wrote:

> You do understand that I was showing what *would* happen if Perl only
> copied SV *'s instead of cloning SV's, right?

Well, even when I re-read your posting, that doesn't jump out at me. But
I'll take your word for it! :-)

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



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

Date: 29 Jun 1998 11:45:43 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: some questions about array refs & efficiency
Message-Id: <6n7up7$ngp$1@pegasus.csx.cam.ac.uk>

Rick Delaney  <rick.delaney@shaw.wave.ca> wrote:
>
>I think that perl is too smart to make a copy here.  After all it
>doesn't iterate through all the keys in this scalar context:
>
>	$numkeys = keys %hash; 

It does iterate if %hash is tied.    :-(


Mike Guy


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

Date: Mon, 29 Jun 1998 23:30:38 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: some questions about array refs & efficiency
Message-Id: <1dbeqaq.vz4b711z0ltnfN@bay2-15.quincy.ziplink.net>

Tom Phoenix <rootbeer@teleport.com> wrote:

> On Mon, 29 Jun 1998, Sean McAfee wrote:
> 
> > You do understand that I was showing what *would* happen if Perl only
> > copied SV *'s instead of cloning SV's, right?
> 
> Well, even when I re-read your posting, that doesn't jump out at me. But
> I'll take your word for it! :-)

Don't worry, Tom, I made the same mistake.  I'd written up a quick
posting showing that his code would print 3, not 4.  But it seemed like
such a silly mistake that I went back and reread his post, just to make
sure.  Right before the sample code I noticed the following.

Sean wrote in his original post:
>
> Internally, a Perl array is an array of pointers.  One *could* make a copy
> of only the pointers, but that would generally result in undesirable
> behavior, eg:

So, he did say it was hypothetical behavior, but, you're right, it
definitely doesn't jump out at you.

Better would have been:

print $b[0];  # would print "4" if only pointers would copied.
              
Oh well.  :-)

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Tue, 30 Jun 1998 11:51:06 -0400
From: "Pap" <Pap22@erols.com>
Subject: Sorting values usings arrays
Message-Id: <6nb1mp$h3o$1@winter.news.erols.com>

Ok, so I have this script, and it is meant to display a player name, with
info about the number of kills and deaths they have, and also, their
percentage, as calculated.  But it just displays in the order it came from
the database, line by line, in the order the data was appended.  I added the
first two lines you see below, but they don't seem to work.

sub bypercent { $percent{$b} <=> $percent{$a} }
foreach $player ( sort bypercent keys($percent) ) {
      print "<tr>";
      print "<td>$player</td>";
      print "<td><p align=right>$kills</td>";
      print "<td><p align=right>$deaths</td>";
      print "<td><p align=right>$percent%</td>";
      print "</tr>\n";
}

Incase this might help, when I took out line #2 but kept #1, the form
displayed fine without any error, even though it wasnt sorted at all.  To
clarify, I want the data to be displayed descending by percentage.  If you
can point out what is wrong with this script, please do, or if you know of
another way I can do it, please enlighten me.  Just incase, this is Perl,
and if you wanna take a look at the entire source code and/or want the url,
just ask me.

Thank you for reading this post and I hope to hear from you.




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

Date: Tue, 30 Jun 1998 09:18:55 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sorting values usings arrays
Message-Id: <MPG.1002afc75a9567f5989706@nntp.hpl.hp.com>

In article <6nb1mp$h3o$1@winter.news.erols.com> on Tue, 30 Jun 1998 
11:51:06 -0400, Pap <Pap22@erols.com> says...
 ... 
> sub bypercent { $percent{$b} <=> $percent{$a} }
> foreach $player ( sort bypercent keys($percent) ) {
                                        ^
                                        %percent

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


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

Date: Tue, 30 Jun 1998 12:50:52 -0400
From: "Pap" <Pap22@erols.com>
Subject: Re: Sorting values usings arrays
Message-Id: <6nb576$2qc$1@winter.news.erols.com>

no this didnt work, perhaps there's something in addition i need to add to
the print lines that follow?

Larry Rosler wrote in message ...
>In article <6nb1mp$h3o$1@winter.news.erols.com> on Tue, 30 Jun 1998
>11:51:06 -0400, Pap <Pap22@erols.com> says...
>...
>> sub bypercent { $percent{$b} <=> $percent{$a} }
>> foreach $player ( sort bypercent keys($percent) ) {
>                                        ^
>                                        %percent
>
>--
>Larry Rosler
>Hewlett-Packard Laboratories
>http://www.hpl.hp.com/personal/Larry_Rosler/
>lr@hpl.hp.com




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

Date: Tue, 30 Jun 1998 10:00:11 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sorting values usings arrays
Message-Id: <MPG.1002b97224e6175f989708@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <6nb1mp$h3o$1@winter.news.erols.com> on Tue, 30 Jun 1998 
11:51:06 -0400, Pap <Pap22@erols.com> says...
> Ok, so I have this script, and it is meant to display a player name, with
> info about the number of kills and deaths they have, and also, their
> percentage, as calculated.  But it just displays in the order it came from
> the database, line by line, in the order the data was appended.  I added the
> first two lines you see below, but they don't seem to work.
> 
> sub bypercent { $percent{$b} <=> $percent{$a} }
> foreach $player ( sort bypercent keys($percent) ) {
>       print "<tr>";
>       print "<td>$player</td>";
>       print "<td><p align=right>$kills</td>";
>       print "<td><p align=right>$deaths</td>";
>       print "<td><p align=right>$percent%</td>";
>       print "</tr>\n";
> }
> 
> Incase this might help, when I took out line #2 but kept #1, the form
> displayed fine without any error, even though it wasnt sorted at all.  To
> clarify, I want the data to be displayed descending by percentage.  If you
> can point out what is wrong with this script, please do, or if you know of
> another way I can do it, please enlighten me.  Just incase, this is Perl,
> and if you wanna take a look at the entire source code and/or want the url,
> just ask me.

There certainly is something about this that you haven't shown.  In the 
code quoted, $kills $deaths and $percent would have the same values (if 
indeed they have values) for every player.  Perhaps what you meant to say 
is $kills{$player} $deaths{$player) $percent{$player}.

There is no reason not to use the '-w' flag on the first line of your 
script (which would warn you about the use of undefined values for the 
variables in your script) and the 'use strict;' pragma (which would 
require you to declare each variable explicitly).

The book 'Learning Perl' from O'Reilly and Associates will save you lots 
of time and grief.

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


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

Date: Mon, 29 Jun 1998 18:09:38 -0700
From: Shawn Bohn <shawn@thememedia.com>
Subject: Speed of embeding PERL into C++
Message-Id: <35983AD2.3253BF92@thememedia.com>

I've embedded PERL engine into my C++ program and have found it to run 2
times slower than on the command line.  I'm not setting any stack
variables, just making the perl_call_argv call that initiates my
program, with one large character array as an input arg. 

Any reasons why this should be slower in the embedded mode than on the
command line?

-Shawn

_____________________________________________________________________
Shawn J. Bohn  				
Senior Information Engineer
				              
ThemeMedia Inc.                     "No theory is good unless one uses
WK:  (425) 602-3558                  it to go beyond."     -Andre Gide
FAX: (425) 602-3570
shawn@thememedia.com
______________________________________________________________________


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

Date: Sun, 28 Jun 1998 21:17:02 GMT
From: jaws@atl.mindspring.com (John Armsby)
Subject: Re: Spider programms in PERL
Message-Id: <6n6c1e$4r9$1@camel19.mindspring.com>

I bought Web Client Programming by Clinton Wong.  Easily
understandable.  Within a short time I could get a list of files from
a web site (hooray).  I will figure out how to get the worm to recurse
directories ( I have an idea how) and then I am done.  I will put a
loop at the beginning to loop throught a list of ip addresses and I
have a poor man's spider.

John

Randal Schwartz <merlyn@stonehenge.com> wrote:

>>>>>> "John" == John Armsby <jaws@atl.mindspring.com> writes:

>John> Now I am in this thread and I read smart alecky remarks telling a
>John> newbie to go to the LWP and other such modules and "figure it out".

>And if you are also reading every article in this thread, at least one
>or two postings also pointed out my WebTechniques columns at
>http://www.stonehenge.com/merlyn/WebTechniques/, which give three
>different spiders to do link validation.

>And please stop whining about "figuring it out".  If you're looking
>for ready-to-run code (or how to configure badly-written ready-to-run
>code :-), that's one kind of request, and will get the lowest priority
>here.  If you're having trouble understanding the LWP docs, that'll
>get a warmer response, because it means we are programmers talking to
>other programmers, "teaching others to fish" as it were.

>print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
>## legal fund: $20,990.69 collected, $186,159.85 spent; just 69 more days
>## before I go to *prison* for 90 days; email fund@stonehenge.com for details

>-- 
>Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
>Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
>Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
>Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
>Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me




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

Date: 29 Jun 1998 11:16:42 GMT
From: sweston@openix.com (sweston)
Subject: SQL Statement Troubles
Message-Id: <6n7t2q$7sl@enews2.newsguy.com>

I am trying to convert an SQL statement from a Powerbuilder application to
a generic statement that I can feed to Oracle SQL.  Unfortunately I'm not
too familiar with Oracle, Powerbuilder, or SQL...  so hopefully someone
can help save some time.

SELECT "TABLE"."FIELD"
FROM "TABLE"
WHERE ("TABLE"."FIELD" like :ra_options)

In powerbuilder, I can have ra_options be a selection box with multiple
entries selected.  I am trying to convert this to a perl application.
I can't do: WHERE ("TABLE"."FIELD" like @ra_options) in perl.  Any idea
if I can compare against an array of values in a single like statement or
how to?

Thanks,
Steve
sweston@openix.com

(Please e-mail directly as I do not regularly read this newsgroup.)


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

Date: Mon, 29 Jun 1998 13:51:54 +0100
From: "Simon" <simon@getreal.demon.co.uk>
Subject: Re: SQL Statement Troubles
Message-Id: <899125981.11998.0.nnrp-08.c1ed0e5f@news.demon.co.uk>

Change your SQL statement to
 ...
WHERE "TABLE"."FIELD" IN :ra_options

ra_options should be defined as a string array.  The value in the retrieve()
statement should be passed as an array, so you need to loop through your
listbox and construct a dynamic array of selected values.

HTH

Simon

sweston wrote in message <6n7t2q$7sl@enews2.newsguy.com>...
>I am trying to convert an SQL statement from a Powerbuilder application to
>a generic statement that I can feed to Oracle SQL.  Unfortunately I'm not
>too familiar with Oracle, Powerbuilder, or SQL...  so hopefully someone
>can help save some time.
>
>SELECT "TABLE"."FIELD"
>FROM "TABLE"
>WHERE ("TABLE"."FIELD" like :ra_options)
>
>In powerbuilder, I can have ra_options be a selection box with multiple
>entries selected.  I am trying to convert this to a perl application.
>I can't do: WHERE ("TABLE"."FIELD" like @ra_options) in perl.  Any idea
>if I can compare against an array of values in a single like statement or
>how to?
>
>Thanks,
>Steve
>sweston@openix.com
>
>(Please e-mail directly as I do not regularly read this newsgroup.)
>




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

Date: 29 Jun 1998 14:51:09 GMT
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: Statistics for comp.lang.perl.misc
Message-Id: <6n89kt$r04$5@info.uah.edu>

Following is a summary of articles spanning a 7 day period,
beginning at 22 Jun 1998 14:07:13 GMT and ending at
29 Jun 1998 22:17:58 GMT.

Notes
=====

    - A line in the body of a post is considered to be original if it
      does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
    - All text after the last cut line (/^-- $/) in the body is
      considered to be the author's signature.
    - The scanner prefers the Reply-To: header over the From: header
      in determining the "real" e-mail address and name.
    - Original Content Rating (OCR) is the ratio of the original content
      volume to the total body volume.
    - Find the News-Scan distribution on the CPAN!
      <URL:http://www.perl.com/CPAN/modules/by-module/News/>
    - Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
    - Copyright (c) 1998 Greg Bacon.  All Rights Reserved.
      Verbatim copying and redistribution is permitted without royalty;
      alteration is not permitted.  Redistribution and/or use for any
      commercial purpose is prohibited.

Excluded Posters
================

perlfaq-suggestions\@mox\.perl\.com

Totals
======

Posters:  543
Articles: 1894 (843 with cutlined signatures)
Threads:  458
Volume generated: 3315.3 kb
    - headers:    1363.0 kb (26,346 lines)
    - bodies:     1811.7 kb (54,453 lines)
    - original:   1234.2 kb (39,649 lines)
    - signatures: 138.8 kb (2,886 lines)

Original Content Rating: 0.681

Averages
========

Posts per poster: 3.5
    median: 1 post
    mode:   1 post - 325 posters
    s:      9.1 posts
Posts per thread: 4.1
    median: 2.0 posts
    mode:   1 post - 132 threads
    s:      9.9 posts
Message size: 1792.5 bytes
    - header:     736.9 bytes (13.9 lines)
    - body:       979.5 bytes (28.8 lines)
    - original:   667.3 bytes (20.9 lines)
    - signature:  75.1 bytes (1.5 lines)

Top 10 Posters by Number of Posts
=================================

         (kb)   (kb)  (kb)  (kb)
Posts  Volume (  hdr/ body/ orig)  Address
-----  --------------------------  -------

  118   184.4 ( 95.7/ 75.1/ 50.4)  Tom Phoenix <rootbeer@teleport.com>
   83   155.7 ( 68.4/ 78.1/ 65.4)  tchrist@mox.perl.com (Tom Christiansen)
   70   126.5 ( 50.1/ 57.0/ 32.2)  Russ Allbery <rra@stanford.edu>
   59    96.4 ( 39.4/ 51.1/ 27.2)  lr@hpl.hp.com (Larry Rosler)
   51    75.5 ( 36.6/ 30.9/ 19.2)  "F.Quednau" <quednauf@nortel.co.uk>
   45    85.9 ( 38.8/ 40.1/ 19.0)  abigail@fnx.com
   31    62.3 ( 22.4/ 39.9/ 28.7)  cberry@cinenet.net (Craig Berry)
   28    49.3 ( 20.6/ 27.8/ 27.3)  fl_aggie@thepentagon.com (I R A Aggie)
   28    32.9 ( 18.0/ 12.7/  7.0)  Jonathan Feinberg <jdf@pobox.com>
   28    66.0 ( 23.6/ 42.4/ 14.1)  Olga <katzman@students.uiuc.edu>

These posters accounted for 28.6% of all articles.

Top 10 Posters by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Address
--------------------------  -----  -------

 184.4 ( 95.7/ 75.1/ 50.4)    118  Tom Phoenix <rootbeer@teleport.com>
 155.7 ( 68.4/ 78.1/ 65.4)     83  tchrist@mox.perl.com (Tom Christiansen)
 126.5 ( 50.1/ 57.0/ 32.2)     70  Russ Allbery <rra@stanford.edu>
  96.4 ( 39.4/ 51.1/ 27.2)     59  lr@hpl.hp.com (Larry Rosler)
  85.9 ( 38.8/ 40.1/ 19.0)     45  abigail@fnx.com
  75.5 ( 36.6/ 30.9/ 19.2)     51  "F.Quednau" <quednauf@nortel.co.uk>
  72.4 ( 18.7/ 47.8/ 31.2)     25  Lloyd Zusman <ljz@asfast.com>
  66.0 ( 23.6/ 42.4/ 14.1)     28  Olga <katzman@students.uiuc.edu>
  62.3 ( 22.4/ 39.9/ 28.7)     31  cberry@cinenet.net (Craig Berry)
  60.5 (  4.2/ 56.3/ 52.5)      3  www.c-zone.net/sidereal/

These posters accounted for 29.7% of the total volume.

Top 10 Posters by OCR (minimum of five posts)
==============================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

1.000  (  5.5 /  5.5)      7  gabor@vmunix.com (Gabor)
0.990  (  8.6 /  8.6)     12  pudge@pobox.com (Chris Nandor)
0.989  (  1.1 /  1.1)      5  Robert.Rehammar@emw.ericsson.se
0.984  ( 27.3 / 27.8)     28  fl_aggie@thepentagon.com (I R A Aggie)
0.971  (  2.2 /  2.2)      7  perlguy@technologist.com
0.915  (  9.0 /  9.8)     10  Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
0.885  (  4.8 /  5.5)      8  gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
0.856  (  3.4 /  4.0)      5  "Matthew O. Persico" <mpersico@erols.com>
0.838  ( 65.4 / 78.1)     83  tchrist@mox.perl.com (Tom Christiansen)
0.817  ( 10.6 / 12.9)     17  smcdow@arlut.utexas.edu (Stuart McDow)

Bottom 10 Posters by OCR (minimum of five posts)
=================================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

0.474  ( 19.0 / 40.1)     45  abigail@fnx.com
0.450  (  2.5 /  5.6)      7  ilya@math.ohio-state.edu (Ilya Zakharevich)
0.433  (  5.6 / 13.0)     14  Deva Seetharam <psdspss@execpc.com>
0.421  ( 13.3 / 31.6)     22  phenix@interpath.com (John Moreno)
0.399  (  4.7 / 11.9)      9  "Eschult" <eschult.NOSPAM@squonk.net>
0.398  (  1.0 /  2.4)      5  chip@mail.atlantic.net (Chip Salzenberg)
0.333  ( 14.1 / 42.4)     28  Olga <katzman@students.uiuc.edu>
0.304  (  2.2 /  7.3)      6  ced@bcstec.ca.boeing.com (Charles DeRykus)
0.289  (  1.5 /  5.1)      7  "Locke" <none@spam.com>
0.210  (  1.3 /  6.3)      6  ac1@fspc.netsys.itg.telecom.com.au (nobody)

73 posters (13%) had at least five posts.

Top 10 Threads by Number of Posts
=================================

Posts  Subject
-----  -------

  139  Flames....
  132  What a Crappy World
   65  What a Crappy World (oh, yes!)
   36  system() and security again
   23  Hiding the Perl source
   21  Can someone explain the arrow operator ?
   21  Sending files via mail in perl
   18  after 5 hrs, the beginner beats the s///
   18  Testing perl knowledge
   18  first language - last language

These threads accounted for 25.9% of all articles.

Top 10 Threads by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Subject
--------------------------  -----  -------

 315.0 (123.7/178.3/109.5)    139  Flames....
 267.7 ( 99.5/161.4/106.0)    132  What a Crappy World
 129.7 ( 58.0/ 66.5/ 35.6)     65  What a Crappy World (oh, yes!)
  72.3 ( 29.8/ 36.3/ 20.0)     36  system() and security again
  56.1 (  1.3/ 54.8/ 51.7)      1  KLAUSE LIES ABOUT PREDICTION
  53.7 ( 12.8/ 39.8/ 34.9)     18  Testing perl knowledge
  44.0 ( 17.0/ 25.4/ 14.8)     23  Hiding the Perl source
  36.4 ( 13.8/ 21.1/ 12.6)     18  after 5 hrs, the beginner beats the s///
  35.6 ( 16.7/ 17.6/ 11.5)     21  Sending files via mail in perl
  33.9 ( 15.1/ 16.7/ 11.5)     17  first language

These threads accounted for 31.5% of the total volume.

Top 10 Threads by OCR (minimum of five posts)
==============================================

         (kb)    (kb)
OCR      orig /  body  Posts  Subject
-----  --------------  -----  -------

0.916  (  7.3/   7.9)      7  ANNOUNCEMENT: clpa doesn't accept perl announcements!
0.894  ( 12.0/  13.4)      8  autovivification and tie questions
0.889  (  4.2/   4.7)      5  print <<STRING;
0.876  ( 34.9/  39.8)     18  Testing perl knowledge
0.861  (  4.5/   5.3)      5  MacPerl and odd filenames
0.854  ( 15.8/  18.5)     10  TIP: How to post good questions
0.831  (  3.2/   3.8)      7  Functions In Perl
0.808  (  3.9/   4.8)      5  use of crypt to encrypt password
0.791  (  1.3/   1.7)      5  ? Moderated clpm ?
0.789  (  2.0/   2.5)      7  Perl and Delphi

Bottom 10 Threads by OCR (minimum of five posts)
=================================================

         (kb)    (kb)
OCR      orig /  body  Posts  Subject
-----  --------------  -----  -------

0.500  (  2.7 /  5.4)      9  MD5 and Perl4
0.499  (  2.8 /  5.7)      5  Uploading perl scripts with a perl script.
0.490  (  1.9 /  3.8)      5  Sending mail through another server?
0.485  (  2.8 /  5.8)      8  Checking if a file does NOT exist
0.484  (  5.7 / 11.8)     18  first language - last language
0.483  (  2.2 /  4.6)      8  newbie Location: syntax help wanted
0.482  (  3.0 /  6.1)      9  How to find last modified date of a file?
0.431  (  1.5 /  3.6)      6  Comparing the contents of an array?
0.430  (  1.4 /  3.3)      5  readling a file
0.363  (  1.3 /  3.6)      5  Perlre needs patch? (was: searching with Perl ?)

105 threads (22%) had at least five posts.

Top 10 Targets for Crossposts
=============================

Articles  Newsgroup
--------  ---------

      25  comp.lang.perl.modules
      21  comp.lang.perl
      18   comp.lang.perl.misc
      17  gnu.misc.discuss
      13  comp.lang.c
      13  comp.programming
       7  comp.lang.perl.tk
       6  alt.html
       5  comp.os.ms-windows.programmer.winhelp
       5  comp.os.ms-windows.programmer.tools.misc

Top 10 Crossposters
===================

Articles  Address
--------  -------

      42  www.c-zone.net/sidereal/
      17  hex@voicenet.com (Matt Knecht)
       9  Gellyfish@btinternet.com (Jonathan Stowe)
       8  bhuston@zeus.anet-chi.com (Bill Huston )
       5  abigail@fnx.com
       4  "Cybervillain" <dbalsillie@email.msn.com>
       4  "Locke" <none@spam.com>
       4  Tom Phoenix <rootbeer@teleport.com>
       4  kaz@cafe.net
       4  chiherbs@primenet.com


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

Date: 28 Jun 1998 11:19:53 GMT
From: Tsang Man Fai <mftsang@cse.cuhk.edu.hk>
Subject: string replacement
Message-Id: <6n58sp$m7t@eng-ser1.erg.cuhk.edu.hk>

I'm a beginner in Perl. I want to replace all occurences of a sub-string
in a string with another substring. 

For example,

 $str = "It's really difficult, really difficult!!!";

after replacement of "difficult" with "simple",

 $str = "It's really simple, really simple!!!";

Is there any simple method to do that?

Philip


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

Date: Sun, 28 Jun 1998 12:42:57 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: string replacement
Message-Id: <35962C41.861222E6@nortel.co.uk>

Tsang Man Fai wrote:
> 
> I'm a beginner in Perl. I want to replace all occurences of a sub-string
> in a string with another substring.

Check out the perlre page, piece of the standard documentation. Especially look
for the s/string1/string2/ construct.

-- 
____________________________________________________________
Frank Quednau               
http://www.surrey.ac.uk/~me51fq
________________________________________________


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

Date: 28 Jun 1998 04:43:33 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: string replacement
Message-Id: <m3btrdycnu.fsf@windlord.Stanford.EDU>

Tsang Man Fai <mftsang@cse.cuhk.edu.hk> writes:

> I'm a beginner in Perl. I want to replace all occurences of a sub-string
> in a string with another substring.

This is a simple enough question that it indicates to me that you've
missed some of the most fundamental points of the language (such as
regular expressions).  I'd highly recommend that you get a good beginner's
book on Perl, as it will fill in these gaps for you.  _Learning Perl_ by
Randal Schwartz and Tom Christiansen is highly recommended.

> For example,

>  $str = "It's really difficult, really difficult!!!";

> after replacement of "difficult" with "simple",

>  $str = "It's really simple, really simple!!!";

$str =~ s/difficult/simple/;

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Sun, 28 Jun 1998 06:48:08 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: string replacement
Message-Id: <MPG.fffe972fecabd209896fd@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <m3btrdycnu.fsf@windlord.Stanford.EDU> on 28 Jun 1998 04:43:33 
-0700, Russ Allbery <rra@stanford.edu> says...
> Tsang Man Fai <mftsang@cse.cuhk.edu.hk> writes:
> 
> > I'm a beginner in Perl. I want to replace all occurences of a sub-string
> > in a string with another substring.
 ...
> $str =~ s/difficult/simple/;

It was very early in the morning when you wrote this, Russ!

$str =~ s/difficult/simple/g;

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


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 3023
**************************************

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