[10688] in Perl-Users-Digest
Perl-Users Digest, Issue: 4280 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 23 15:07:24 1998
Date: Mon, 23 Nov 98 12:01:20 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 23 Nov 1998 Volume: 8 Number: 4280
Today's topics:
Changing the env variables? (Emmanouil Spyridakis)
Re: Deleting GDBM file records (Jon Drukman)
Re: Does (.*?) do what I think it does? ptimmins@netserv.unmc.edu
Re: Does (.*?) do what I think it does? (David Formosa)
How to call PGP from Perl Script? <hannum@ohio.edu>
Re: How to call PGP from Perl Script? <dan@clockwork.net>
Re: How to print a simple character on the screen ? (Larry Rosler)
Re: How to print a simple character on the screen ? (Tad McClellan)
Re: How to print a simple character on the screen ? (Larry Rosler)
Re: How to print a simple character on the screen ? (Matthew Bafford)
Re: htpasswd source code (+ crypt) <Allan@due.net>
New posters to comp.lang.perl.misc <gbacon@cs.uah.edu>
Re: Question from a mega-geek (Bradley K. Farrell)
Re: Regex for Matching Text Outside HTML Tags <dan@clockwork.net>
Re: Required Fields --HELP <dan@clockwork.net>
Re: simple include <r28629@email.sps.mot.com>
Re: Sorting DB but starting in middle (Larry Rosler)
Statistics for comp.lang.perl.misc <gbacon@cs.uah.edu>
Strange behaviour of nonblocking socket! <dennis@bilbo.iok.net>
Re: Strings instead of regular expressions (Matthew Bafford)
Re: Sum by group ptimmins@netserv.unmc.edu
Re: where are libnet and Digest::MD5 <dan@clockwork.net>
Win32:FileSecurity: Writing ACL's <feskencj@plu.edu>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 23 Nov 1998 18:35:12 GMT
From: espyrida@osf1.gmu.edu (Emmanouil Spyridakis)
Subject: Changing the env variables?
Message-Id: <73c9t0$ue0@portal.gmu.edu>
When I submit a form to a perl script in a web page I want to change the
values of some of the variables before I create the new page on the fly
through perl.
I have been trying to do this by changing the environmental variable
'QUERY_STRING' but perl always puts the old variables on the Address line
of my browser no matter what I do (i.e.
http://www.one.com/entry.plx?name=steve&number=345234523)
How do I change these values?
This is what I tried with the 'QUERY_STRING' when trying to change the
number to something else dut it didn't work:
$vars= $ENV{'QUERY_STRING'} ;
($first, $second, $third) = split(/=/, $vars);
$ENV{'QUERY_STRING'}=$first."=".$second."=".$newvalue;
------------------------------
Date: 23 Nov 1998 19:30:42 GMT
From: jsd@hudsucker.gamespot.com (Jon Drukman)
Subject: Re: Deleting GDBM file records
Message-Id: <slrn75je93.bnr.jsd@hudsucker.gamespot.com>
In article <36585E86.4747D72B@magma.ca>, hassan wrote:
>The code below would "delete" all the records in a GDBM file, but
>the file size remains almost the same!! Anybody knows why? I tried
>to vi the "myfile" and found all the records still in there! Does
>anybody know how I can "sure delete" GDBM file records. That is, if
>my GDBM file is 2MB big, I want to see the size of that file
>considerably reduced after deleting all the records.
can't be done unless you copy the records you want to a new file.
gdbm files keep their unused space allocated. in fact, most dbm
implementations that i am aware of behave the same way.
--
Jon Drukman jsd@gamespot.com
-----------------------------------------------------------------------
Fear the government that fears your computer.
------------------------------
Date: Mon, 23 Nov 1998 18:54:31 GMT
From: ptimmins@netserv.unmc.edu
Subject: Re: Does (.*?) do what I think it does?
Message-Id: <73cb0u$296$1@nnrp1.dejanews.com>
In article <36591C31.ED7D26CD@hsr.ch>,
Bernd Nies <bnies@hsr.ch> wrote:
[snip]
> .* means a character apperars zero or more times (a comma
> is also a charachter)
> .? means a charachter may or may not match.
> .*? useless
$string = "This is useless if you decide to make it useless";
print $1 if ($string =~ /(.*?useless)/);
Patrick Timmins
$monger{Omaha}[0]
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 23 Nov 1998 19:27:07 GMT
From: dformosa@zeta.org.au (David Formosa)
Subject: Re: Does (.*?) do what I think it does?
Message-Id: <slrn75jdob.bnf.dformosa@godzilla.zeta.org.au>
In article <36591C31.ED7D26CD@hsr.ch>, Bernd Nies wrote:
[...]
>.* means a character apperars zero or more times (a comma
> is also a charachter)
>.? means a charachter may or may not match.
>.*? useless
.*? means non greedy match.
Which while often miss used isn't useless.
--
Please excuse my spelling as I suffer from agraphia. See
http://www.zeta.org.au/~dformosa/Spelling.html to find out more.
------------------------------
Date: Mon, 23 Nov 1998 18:34:09 GMT
From: "Dave Hannum" <hannum@ohio.edu>
Subject: How to call PGP from Perl Script?
Message-Id: <F2w0qG.9z3@boss.cs.ohiou.edu>
Hello,
I have a Perl shopping cart program that sends the orders to the owner via
email. The shopping cart itself sets in the https:// directory. The ISP
has PGP on their server and says I can use it from my script. The owner has
a PGP key. The problem is, I can't get the script to call PGP properly.
the man pgpe tells me to call it this way:
/usr/bin/pgpe -t email@address.com but this does not
work. (This is the correct path to pgpe by the way). The ISP doesn't have a
clue as to how I can call it either. Has anybody had any experience with
this? I'd appreciate a heads up.
Thanks,
Dave Hannum
skyward@frognet.net
------------------------------
Date: Mon, 23 Nov 1998 12:52:40 -0600
From: Dan Brian <dan@clockwork.net>
Subject: Re: How to call PGP from Perl Script?
Message-Id: <3659AEF8.9A0B8302@clockwork.net>
There is a module for calling PGP 2.6.2 properly at :
http://www.perl.com/CPAN-local/modules/by-module/PGP/
Dave Hannum wrote:
> Hello,
>
> I have a Perl shopping cart program that sends the orders to the owner via
> email. The shopping cart itself sets in the https:// directory. The ISP
> has PGP on their server and says I can use it from my script. The owner has
> a PGP key. The problem is, I can't get the script to call PGP properly.
> the man pgpe tells me to call it this way:
> /usr/bin/pgpe -t email@address.com but this does not
> work. (This is the correct path to pgpe by the way). The ISP doesn't have a
> clue as to how I can call it either. Has anybody had any experience with
> this? I'd appreciate a heads up.
>
> Thanks,
> Dave Hannum
> skyward@frognet.net
------------------------------
Date: Mon, 23 Nov 1998 10:20:11 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to print a simple character on the screen ?
Message-Id: <MPG.10c34736b4b482ce989885@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <36599734.7D18B552@bigfoot.com> on Mon, 23 Nov 1998 12:11:16
-0500, Jean-Gael Gricourt <acetone@bigfoot.com> says...
>
> I got a variable which contains the Ascii code of a letter for
> the alphabet: $letter=\x47; which represents the letter 'G'
>
> print "$letter";
>
> doesn't print the letter actually...
I don't think you mean
$letter = \x47;
which is not valid Perl. Others have assumed that you meant
$letter = "\x47";
which trivially prints 'G'. If that were the case, I don't think you
would have posted your question! I think you mean
$letter = 0x47;
in which case you need to convert that value to a character, which is
done by the 'chr' function:
print chr $letter;
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 23 Nov 1998 13:37:30 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How to print a simple character on the screen ?
Message-Id: <qhdc37.nke.ln@flash.net>
Larry Rosler (lr@hpl.hp.com) wrote:
: [Posted to comp.lang.perl.misc and a copy mailed.]
: In article <36599734.7D18B552@bigfoot.com> on Mon, 23 Nov 1998 12:11:16
: -0500, Jean-Gael Gricourt <acetone@bigfoot.com> says...
: >
: > I got a variable which contains the Ascii code of a letter for
: > the alphabet: $letter=\x47; which represents the letter 'G'
: >
: > print "$letter";
: >
: > doesn't print the letter actually...
: I don't think you mean
: $letter = \x47;
: which is not valid Perl. Others have assumed that you meant
^^^^^^^^^^^^^^
This works fine for me:
-----------------------
#!/usr/bin/perl -w
$letter = \x47; # take a reference to constant (bare) string
print "$letter\n"; # oops, whats that SCALAR(...) stuff? ;-)
print "$$letter\n"; # print the three characters referenced
-----------------------
2:9 ratio now... ;-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 23 Nov 1998 11:28:27 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to print a simple character on the screen ?
Message-Id: <MPG.10c3573278e1f9b7989887@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <qhdc37.nke.ln@flash.net> on Mon, 23 Nov 1998 13:37:30 -0600,
Tad McClellan <tadmc@flash.net> says...
> Larry Rosler (lr@hpl.hp.com) wrote:
...
> : I don't think you mean
>
> : $letter = \x47;
>
> : which is not valid Perl. Others have assumed that you meant
> ^^^^^^^^^^^^^^
>
> This works fine for me:
>
> -----------------------
> #!/usr/bin/perl -w
use strict; # 'valid Perl' == 'use strict;' :-)
> $letter = \x47; # take a reference to constant (bare) string
>
> print "$letter\n"; # oops, whats that SCALAR(...) stuff? ;-)
>
> print "$$letter\n"; # print the three characters referenced
> -----------------------
>
>
> 2:9 ratio now... ;-)
Count all you want, Tad, if it makes you feel any better. :-)
It is not valid Perl with 'use strict;' (ergo, IMO, it is not valid Perl
-- if one wants symbolic references, one should use 'use strict;'
supplemented by 'no strict q(refs);' in the right places). And it was
not what the submitter meant to type in any case (and in neither case
did he type "\x47" as the other responders blithely assumed). He meant
to type 0x47, and he was looking for the 'chr' function.
I'll stand by the acknowledgment I got via email:
Thanks a lot for your answer !
Sorry about the mistakes, I wrote my message in 10 sec :)
Basically I knew that such Perl function existed but couldn't
remember the name.
Jean
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 23 Nov 1998 14:58:01 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: How to print a simple character on the screen ?
Message-Id: <MPG.10c3884328c7d1298972e@news.scescape.net>
In article <36599734.7D18B552@bigfoot.com>, acetone@bigfoot.com says...
=>
=> I got a variable which contains the Ascii code of a letter for
=> the alphabet: $letter=\x47; which represents the letter 'G'
=>
=> print "$letter";
=>
=> doesn't print the letter actually...
=>
=> Does anyone know how to do that in Perl ?
In the off chance you are reading the number in from a file (or assigning
as in '= 65'):
print chr($letter);
=> Thank you,
Probably didn't help; I think the others are a little closer to your
problem...
=> Jean
--Matthew
------------------------------
Date: Mon, 23 Nov 1998 13:19:49 -0500
From: "AmD" <Allan@due.net>
Subject: Re: htpasswd source code (+ crypt)
Message-Id: <73c8nc$pqg$1@camel21.mindspring.com>
Andrew Chapas wrote in message <73c4pd$3pr3@Talisker.taide.net>...
>Hi!
>Need source code for Java of Unix htpasswd utility (together with crypt.c)
>Together with "crypt()" source code.
>Thanks!
>Andrew
Well, since this question has nothing to do with Perl, why don't we use Perl
to show you one way to answer it.
#!/usr/local/bin/perl -w
use strict;
use LWP::Simple;
use HTML::Parse
require HTML::FormatText;
my $htmlinfo =
get("http://ink.yahoo.com/bin/query?p=JAVA+crypt+htpasswd+crypt.c&hc=0&hs=4"
);
my $info = parse_html($htmlinfo);
my $formatter = new HTML::FormatText;
print $formatter->format($info);
AmD
I think I will just keep posting this script all day. Just in that kind of
mood.
[removed all those nasty crossposts]
------------------------------
Date: 23 Nov 1998 19:48:19 GMT
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: New posters to comp.lang.perl.misc
Message-Id: <73ce63$1t1$3@info.uah.edu>
Following is a summary of articles from new posters spanning a 7 day
period, beginning at 16 Nov 1998 15:03:10 GMT and ending at
23 Nov 1998 06:02:19 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" email 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.
Totals
======
Posters: 207 (46.3% of all posters)
Articles: 287 (26.6% of all articles)
Volume generated: 472.7 kb (26.8% of total volume)
- headers: 194.8 kb (4,082 lines)
- bodies: 269.9 kb (8,356 lines)
- original: 202.6 kb (6,584 lines)
- signatures: 7.8 kb (180 lines)
Original Content Rating: 0.751
Averages
========
Posts per poster: 1.4
median: 1 post
mode: 1 post - 156 posters
s: 0.9 posts
Message size: 1686.6 bytes
- header: 695.1 bytes (14.2 lines)
- body: 962.8 bytes (29.1 lines)
- original: 722.8 bytes (22.9 lines)
- signature: 27.7 bytes (0.6 lines)
Top 10 Posters by Number of Posts
=================================
(kb) (kb) (kb) (kb)
Posts Volume ( hdr/ body/ orig) Address
----- -------------------------- -------
6 12.5 ( 3.1/ 7.9/ 5.6) gward@thrak.cnri.reston.va.us (Greg Ward)
5 8.1 ( 3.8/ 4.3/ 2.9) sara starre <nospam.perl_rocks@hotmail.com>
5 7.4 ( 3.7/ 3.5/ 2.2) jonathan@core.dumped.org (Jonathan Bobin)
4 5.5 ( 2.5/ 3.0/ 1.8) "+X%J(Tony)" <tonyt@hknet.com>
4 6.6 ( 3.4/ 3.2/ 1.0) "eva m. klopper" <eva_spiral@hotmail.com>
4 4.7 ( 2.5/ 2.2/ 2.2) Sylvain Lavigne <proband@cam.org>
3 14.7 ( 2.0/ 12.7/ 12.5) Christian Ismer <Ismer@oneMission.com>
3 4.2 ( 1.9/ 2.3/ 1.8) James Cameron <james@MatadorDesign.com>
3 5.8 ( 1.7/ 3.4/ 1.5) jwl@worldmusic.de (Joergen W. Lang)
3 4.4 ( 2.2/ 2.2/ 1.1) *ace*@programmer.net (Thomas Jordan)
These posters accounted for 3.7% of all articles.
Top 10 Posters by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Address
-------------------------- ----- -------
22.2 ( 1.4/ 20.8/ 18.8) 2 "Scott Winterstein" <sw12467@advancedits.com>
14.7 ( 2.0/ 12.7/ 12.5) 3 Christian Ismer <Ismer@oneMission.com>
12.5 ( 3.1/ 7.9/ 5.6) 6 gward@thrak.cnri.reston.va.us (Greg Ward)
8.1 ( 3.8/ 4.3/ 2.9) 5 sara starre <nospam.perl_rocks@hotmail.com>
7.4 ( 3.7/ 3.5/ 2.2) 5 jonathan@core.dumped.org (Jonathan Bobin)
7.2 ( 1.1/ 6.0/ 3.4) 1 fleye@my-dejanews.com
6.8 ( 2.3/ 4.5/ 2.8) 3 everybodydies@my-dejanews.com
6.6 ( 3.4/ 3.2/ 1.0) 4 "eva m. klopper" <eva_spiral@hotmail.com>
6.5 ( 2.1/ 4.3/ 2.9) 3 Jonathan Callahan <callahan@pmel.noaa.gov>
6.5 ( 2.1/ 4.4/ 0.9) 3 claes_no_spam@canit.se (Claes Bjorklund)
These posters accounted for 5.6% of the total volume.
Top 10 Posters by OCR (minimum of three posts)
==============================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
1.000 ( 2.2 / 2.2) 4 Sylvain Lavigne <proband@cam.org>
0.981 ( 12.5 / 12.7) 3 Christian Ismer <Ismer@oneMission.com>
0.873 ( 2.7 / 3.1) 3 jdl@iasi.com
0.833 ( 1.5 / 1.8) 3 email@address.com
0.830 ( 3.3 / 4.0) 3 "Shawn Berg" <sberg1@tampabay.rr.com>
0.796 ( 1.8 / 2.3) 3 James Cameron <james@MatadorDesign.com>
0.717 ( 2.6 / 3.6) 3 Jarrod Stenberg <jarrod@alcmn.org>
0.712 ( 5.6 / 7.9) 6 gward@thrak.cnri.reston.va.us (Greg Ward)
0.676 ( 2.9 / 4.3) 5 sara starre <nospam.perl_rocks@hotmail.com>
0.671 ( 2.9 / 4.3) 3 Jonathan Callahan <callahan@pmel.noaa.gov>
Bottom 10 Posters by OCR (minimum of three posts)
=================================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.671 ( 2.9 / 4.3) 3 Jonathan Callahan <callahan@pmel.noaa.gov>
0.616 ( 2.8 / 4.5) 3 everybodydies@my-dejanews.com
0.613 ( 1.8 / 3.0) 4 "+X%J(Tony)" <tonyt@hknet.com>
0.610 ( 2.2 / 3.5) 5 jonathan@core.dumped.org (Jonathan Bobin)
0.545 ( 1.5 / 2.7) 3 Evert Smit <admin@sidhe.net>
0.498 ( 1.1 / 2.2) 3 *ace*@programmer.net (Thomas Jordan)
0.493 ( 1.1 / 2.2) 3 matt@teamamiga.org
0.446 ( 1.5 / 3.4) 3 jwl@worldmusic.de (Joergen W. Lang)
0.325 ( 1.0 / 3.2) 4 "eva m. klopper" <eva_spiral@hotmail.com>
0.208 ( 0.9 / 4.4) 3 claes_no_spam@canit.se (Claes Bjorklund)
19 posters (9%) had at least three posts.
Top 10 Crossposters
===================
Articles Address
-------- -------
6 moo@cow.com.hehehe (Mick)
6 edbj@ix.netcom.com (Ed Jay)
6 Roger <roger@nospam.nationwideisp.net>
4 "john lampe" <j_lampe@bellsouth.net>
4 "Peter Moore" <pmoore@interaccess.com>
3 matt@teamamiga.org
3 "Craig Horton" <CHorton@STSSystems.com>
3 jwarner@texas.net
2 nestor fernandez <nestor_fernandez@hp.com>
2 fleye@my-dejanews.com
------------------------------
Date: Mon, 23 Nov 1998 17:31:10 GMT
From: bradley@iinet.net.au (Bradley K. Farrell)
Subject: Re: Question from a mega-geek
Message-Id: <365a98f8.972763549@news.m.iinet.net.au>
My local bookstore had some "Republic" metal badges, and I must admit
B-) that I grabbed one. It's about 2 inches wide, and is blue and
orange in colour. It's not as cool as a cloth badge could be (IMHO),
but it might satisfy your geek chic. I doubt there are any left now.
But if I ever see them again, I'll grab one for you.
BTW, The Perl Journal has fridge magnets for sale.
--
Bradley K. Farrell
bradley@iinet.net.au
------------------------------
Date: Mon, 23 Nov 1998 12:47:10 -0600
From: Dan Brian <dan@clockwork.net>
Subject: Re: Regex for Matching Text Outside HTML Tags
Message-Id: <3659ADAE.7D9A627D@clockwork.net>
Very true. This regex isn't the best way to do it; however, the post requested a
regex that would match only non-html elements, meaning, no comments. Also, the
regex is the perlfaq is especially greedy, matching any angled brackets within
brackets. To allow quoted brackets, do a split with:
(<[^>"]*(?:"[^"]*"[^>"]*)*>)
Martien Verbruggen wrote:
> In article <365743BA.FCBAE1B9@clockwork.net>,
> Dan Brian <dan@clockwork.net> writes:
> > A quickie would be:
> >
> > @textonly = split(/<[^>]*>)/);
>
> This will not compile.
>
Yep, typo. Meant: split(/<[^>]*>/);
> > $textonly = join ('', split (/<[^>]*>/));
> >
> > or, to take all HTML tags out of a document,
> >
> > $textonly = $htmltext =~ s/<[^>]*>//g;
>
> Have you seen what the perl FAQ has to say about this sort of
> approach?
>
> # perldoc perlfaq9
> How do I remove HTML from a string?
> [snip]
> Many folks attempt a simple-minded regular expression
> approach, like s/<.*?>//g, but that fails in many cases
> because the tags may continue over line breaks, they may
> contain quoted angle-brackets, or HTML comment may be
> present.
> [snip]
>
> Martien
> --
> Martien Verbruggen |
> Webmaster www.tradingpost.com.au | Little girls, like butterflies, need no
> Commercial Dynamics Pty. Ltd. | excuse - Lazarus Long
> NSW, Australia |
------------------------------
Date: Mon, 23 Nov 1998 12:49:34 -0600
From: Dan Brian <dan@clockwork.net>
Subject: Re: Required Fields --HELP
Message-Id: <3659AE3E.7FDC4F93@clockwork.net>
good call.
------------------------------
Date: Mon, 23 Nov 1998 12:21:35 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: Phil Harris <harrisp2@cf.ac.uk>
Subject: Re: simple include
Message-Id: <3659A7AF.AF6849AB@email.sps.mot.com>
[posted to c.l.p.m and copy emailed]
Phil Harris wrote:
>
> Hi all,
>
> I hope this is not a FAQ but here goes anyway.
>
> Is there a simple way to include a file, not a module just some init
> strings, from the current directory.
>
Simple. Just 'do' it ;)
-TK
------------------------------
Date: Mon, 23 Nov 1998 10:45:04 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sorting DB but starting in middle
Message-Id: <MPG.10c34d07d870f20c989886@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <365926e8.470298@news.supernews.com> on Mon, 23 Nov 1998
09:32:31 GMT, Mark Thompson <mark-lists@webstylists.com> says...
> I have a database program that sorts by record number (the database is in
> alphabetical order already) and I would like it to start in a random part of
> the database, continue to the end, and then finish up from the beginning.
>
> It currently prints the list with this command:
>
> print @hit_list[ sort bydborder $[..$#hit_list ];
>
> using for bydborder:
>
> sub bydborder { $recnum[$a] <=> $recnum[$b]; }
>
> Record number is an integer from 1 through about 2000 but is not continuous.
> It can be something like 2, 3, 5, 10, 12, 19, 20, 21, 22, 23. Basically, in
> this case, each number needs to have a 1 in 10 chance in being the first
> number picked and then go to the end before finishing up at the beginning.
> For example, let's say that 10 was picked first, it would be 10, 12, 19, 20,
> 21, 22, 23, 2, 3, 5 in that order.
There was a recent thread on how best to rotate the contents of an
array. The following approach is simplest, but by no means the most
efficient (I am ignoring your deprecated use of $[, which I presume is
zero in any case):
my @sorted = sort bydborder 0 .. $#hit_list;
my $first = rand @sorted;
print @hit_list[ @sorted[ $first .. $#sorted, 0 .. $first - 1 ] ];
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 23 Nov 1998 19:49:04 GMT
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: Statistics for comp.lang.perl.misc
Message-Id: <73ce7g$1t1$4@info.uah.edu>
Following is a summary of articles spanning a 7 day period,
beginning at 16 Nov 1998 15:03:10 GMT and ending at
23 Nov 1998 06:02:19 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" email 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: 447
Articles: 1078 (411 with cutlined signatures)
Threads: 364
Volume generated: 1760.9 kb
- headers: 747.2 kb (15,539 lines)
- bodies: 943.2 kb (30,267 lines)
- original: 640.3 kb (22,055 lines)
- signatures: 69.5 kb (1,566 lines)
Original Content Rating: 0.679
Averages
========
Posts per poster: 2.4
median: 1 post
mode: 1 post - 273 posters
s: 3.8 posts
Posts per thread: 3.0
median: 2.0 posts
mode: 1 post - 128 threads
s: 3.1 posts
Message size: 1672.7 bytes
- header: 709.7 bytes (14.4 lines)
- body: 895.9 bytes (28.1 lines)
- original: 608.2 bytes (20.5 lines)
- signature: 66.0 bytes (1.5 lines)
Top 10 Posters by Number of Posts
=================================
(kb) (kb) (kb) (kb)
Posts Volume ( hdr/ body/ orig) Address
----- -------------------------- -------
46 67.5 ( 35.9/ 26.1/ 16.8) Tom Phoenix <rootbeer@teleport.com>
30 57.3 ( 24.3/ 26.7/ 19.8) mgjv@comdyn.com.au (Martien Verbruggen)
28 42.9 ( 17.2/ 22.5/ 13.8) lr@hpl.hp.com (Larry Rosler)
21 36.7 ( 13.1/ 20.3/ 10.8) Uri Guttman <uri@fastengines.com>
20 32.5 ( 15.7/ 16.8/ 5.9) Tk Soh <r28629@email.sps.mot.com>
18 26.8 ( 10.5/ 16.3/ 10.3) tadmc@flash.net (Tad McClellan)
17 24.4 ( 12.5/ 9.4/ 4.4) comdog@computerdog.com (brian d foy)
15 26.9 ( 7.4/ 19.2/ 15.7) aml@world.std.com (Andrew M. Langmead)
14 13.9 ( 8.1/ 5.8/ 5.5) fl_aggie@thepentagon.com (I R A Aggie)
14 22.8 ( 10.8/ 7.5/ 4.2) perlguy@technologist.com
These posters accounted for 20.7% of all articles.
Top 10 Posters by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Address
-------------------------- ----- -------
67.5 ( 35.9/ 26.1/ 16.8) 46 Tom Phoenix <rootbeer@teleport.com>
57.3 ( 24.3/ 26.7/ 19.8) 30 mgjv@comdyn.com.au (Martien Verbruggen)
42.9 ( 17.2/ 22.5/ 13.8) 28 lr@hpl.hp.com (Larry Rosler)
36.7 ( 13.1/ 20.3/ 10.8) 21 Uri Guttman <uri@fastengines.com>
32.5 ( 15.7/ 16.8/ 5.9) 20 Tk Soh <r28629@email.sps.mot.com>
26.9 ( 7.4/ 19.2/ 15.7) 15 aml@world.std.com (Andrew M. Langmead)
26.8 ( 10.5/ 16.3/ 10.3) 18 tadmc@flash.net (Tad McClellan)
26.8 ( 9.1/ 17.7/ 9.6) 13 dave@mag-sol.com
24.6 ( 8.5/ 12.8/ 6.7) 11 Uri Guttman <uri@sysarch.com>
24.4 ( 12.5/ 9.4/ 4.4) 17 comdog@computerdog.com (brian d foy)
These posters accounted for 20.8% of the total volume.
Top 10 Posters by OCR (minimum of five posts)
==============================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.993 ( 4.6 / 4.6) 5 tye@fohnix.metronet.com (Tye McQueen)
0.951 ( 5.5 / 5.8) 14 fl_aggie@thepentagon.com (I R A Aggie)
0.901 ( 7.7 / 8.5) 7 "Xah" <xah@best.com>
0.818 ( 15.7 / 19.2) 15 aml@world.std.com (Andrew M. Langmead)
0.789 ( 4.9 / 6.3) 6 dturley@pobox.com
0.770 ( 7.8 / 10.1) 6 ptimmins@netserv.unmc.edu (Patrick Timmins)
0.743 ( 19.8 / 26.7) 30 mgjv@comdyn.com.au (Martien Verbruggen)
0.712 ( 5.6 / 7.9) 6 gward@thrak.cnri.reston.va.us (Greg Ward)
0.701 ( 6.6 / 9.4) 9 eln@cyberhighway.net (Erik)
0.689 ( 3.0 / 4.4) 6 Gareth Rees <garethr@cre.canon.co.uk>
Bottom 10 Posters by OCR (minimum of five posts)
=================================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.461 ( 3.0 / 6.6) 5 randy@theory.uwinnipeg.ca (Randy Kobes)
0.449 ( 0.6 / 1.4) 5 "Ronald Gvggel" <rgoeggel@atos-group.com>
0.438 ( 1.1 / 2.4) 5 pete@theory2.phys.cwru.edu (Peter J. Kernan)
0.422 ( 1.5 / 3.7) 7 Balazs Rauznitz <prauz@sprynet.com>
0.402 ( 1.4 / 3.4) 5 bhilton@tsg.adc.com (Brand Hilton)
0.352 ( 5.9 / 16.8) 20 Tk Soh <r28629@email.sps.mot.com>
0.346 ( 0.7 / 1.9) 5 Eric Bohlman <ebohlman@netcom.com>
0.330 ( 1.3 / 4.0) 5 "Kumar Sundaram" <softsci@eagle.ca>
0.315 ( 1.2 / 3.7) 6 bill@astro.fccj.org
0.179 ( 0.6 / 3.5) 5 baliga@synopsys.com
46 posters (10%) had at least five posts.
Top 10 Threads by Number of Posts
=================================
Posts Subject
----- -------
39 Perl Usage Survey - interpretations, anyone?
19 Holy Abounding Books, Batman!
17 Two-Part RE question
15 Intermediate Perl questions
13 Strange Failure
13 Q: bulk-assign associative array?
13 How do i trim a string in Perl??
12 Beginner Book?
11 how to get `date` in perl for win32 (newbie)
10 HELP: how to prompt for input from command line?
These threads accounted for 15.0% of all articles.
Top 10 Threads by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Subject
-------------------------- ----- -------
76.7 ( 29.5/ 44.4/ 23.4) 39 Perl Usage Survey - interpretations, anyone?
39.3 ( 12.9/ 23.6/ 14.5) 17 Two-Part RE question
37.4 ( 13.7/ 22.0/ 15.1) 19 Holy Abounding Books, Batman!
25.3 ( 10.6/ 13.4/ 9.0) 15 Intermediate Perl questions
18.1 ( 8.0/ 9.5/ 5.5) 13 Q: bulk-assign associative array?
17.8 ( 8.3/ 8.6/ 4.3) 11 how to get `date` in perl for win32 (newbie)
17.6 ( 9.0/ 7.6/ 5.5) 13 How do i trim a string in Perl??
17.6 ( 6.7/ 10.0/ 6.8) 9 Perl script to automatically find dependencies
17.5 ( 7.8/ 9.0/ 6.9) 12 Beginner Book?
16.8 ( 6.0/ 10.5/ 5.0) 9 Sum by group
These threads accounted for 16.1% of the total volume.
Top 10 Threads by OCR (minimum of five posts)
==============================================
(kb) (kb)
OCR orig / body Posts Subject
----- -------------- ----- -------
0.791 ( 1.3/ 1.7) 5 Problem with $O, need help
0.789 ( 6.3/ 8.0) 6 perl documentation date
0.784 ( 4.9/ 6.3) 5 Calling functions from a hash
0.767 ( 6.9/ 9.0) 12 Beginner Book?
0.763 ( 1.9/ 2.5) 5 Auto Incrementing Characters-a subtle problem?
0.758 ( 2.0/ 2.6) 5 Perl vs C
0.745 ( 2.7/ 3.6) 5 interpolate please?
0.724 ( 5.5/ 7.6) 13 How do i trim a string in Perl??
0.717 ( 4.7/ 6.6) 5 programing fun: trees: FlattenAt
0.705 ( 3.0/ 4.3) 5 NT security + IIS + perl
Bottom 10 Threads by OCR (minimum of five posts)
=================================================
(kb) (kb)
OCR orig / body Posts Subject
----- -------------- ----- -------
0.527 ( 1.6 / 3.1) 5 Wanted: Development Partner
0.526 ( 23.4 / 44.4) 39 Perl Usage Survey - interpretations, anyone?
0.525 ( 4.5 / 8.7) 8 Smarter Web Mailer
0.518 ( 2.7 / 5.2) 6 Win32 executing a .pl or .cgi
0.506 ( 1.7 / 3.4) 5 create variable name from a variable in perl
0.503 ( 4.3 / 8.6) 11 how to get `date` in perl for win32 (newbie)
0.492 ( 2.3 / 4.6) 6 Is it possible to run a web server on Win95?
0.479 ( 5.0 / 10.5) 9 Sum by group
0.423 ( 1.7 / 4.0) 6 Need to find binary data
0.416 ( 2.1 / 5.2) 8 check for leading numerics and return error
56 threads (15%) had at least five posts.
Top 10 Targets for Crossposts
=============================
Articles Newsgroup
-------- ---------
29 comp.lang.perl.modules
28 comp.lang.perl
17 alt.perl
5 comp.lang.javascript
4 alt.netscape
4 netscape.public.mozilla.java
4 comp.lang.java.help
4 alt.html
3 comp.os.ms-windows.nt.admin.misc
3 comp.databases.oracle
Top 10 Crossposters
===================
Articles Address
-------- -------
6 Bill Chapman <bchapman@best.com>
6 edbj@ix.netcom.com (Ed Jay)
6 moo@cow.com.hehehe (Mick)
6 Roger <roger@nospam.nationwideisp.net>
4 "Peter Moore" <pmoore@interaccess.com>
4 "john lampe" <j_lampe@bellsouth.net>
4 dturley@pobox.com
4 dave@mag-sol.com
3 Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
3 "Craig Horton" <CHorton@STSSystems.com>
------------------------------
Date: Mon, 23 Nov 1998 19:08:18 +0100
From: Dennis Wetzig <dennis@bilbo.iok.net>
Subject: Strange behaviour of nonblocking socket!
Message-Id: <3659A491.F148388C@bilbo.iok.net>
Hi,
I am kinda clueless here:
I open a socket, use fcntl to make it nonblocking, and if I am doing a
read() or recv() or whatever, the function blocks here? Why is that? Has
anybody an explanation for that?
What I want to do is read from a socket, if soth is there to read...if
not just go further and try again later.
Please let me know, if you have any ideas about it! Any solution about
this problem is greatly appreciated!
Thanks in advance,
Dennis
P.S.: It would be very nice if you could send a copy of your response to
dennis@bilbo.iok.net. Thanks!
------------------------------
Date: Mon, 23 Nov 1998 14:57:59 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Strings instead of regular expressions
Message-Id: <MPG.10c3883ef5a4ea9a98972d@news.scescape.net>
In article <73bppr$6ea$4@news0-alterdial.uu.net>,
gward@thrak.cnri.reston.va.us says...
[snip]
=> For your second problem -- replacing an arbitrary string -- it might be
=> nice if Perl had a builtin 'replace', like Python's string module
=> does, analogous to 'index'... but it doesn't. Instead, you have to use
=> s///.
You could roll your own:
# Tested, but may not be great...
# I'm kinda groggy. :)
use Carp;
sub replace(\$$$) {
carp "Not enough arguments for replace.\n" if @_ != 3;
my ( $str, $indx, $replace ) = @_;
my ( $count, $pos ) = (0, 0);
# != -1 would work as well -- _ass_u_me_ing you haven't touched $[
while ( ($pos = index($$str, $indx, $pos)) >= $[ ) {
substr($$str, $pos, length($indx)) = $replace;
++$count;
}
$count;
}
[snip]
=> documented in 'perlop'.) (The existence of quotemeta, of course, means
=> you can use m// to find $str rather than 'index'. 'index' should be
=> faster, though.
You'd think, wouldn't you? It is _now_, but for a while, the regex was
actually faster... :(
=> Greg
HTH,
--Matthew
------------------------------
Date: Mon, 23 Nov 1998 19:24:37 GMT
From: ptimmins@netserv.unmc.edu
Subject: Re: Sum by group
Message-Id: <73ccp0$3so$1@nnrp1.dejanews.com>
In article <73bvki$okh$1@nnrp1.dejanews.com>,
ptimmins@netserv.unmc.edu (Patrick Timmins) wrote:
[snip]
> Now the hubris in me has overtaken the laziness and impatience of
> my earlier response in this thread, and I *must* post a more elegant
> version of my original solution:
[snip]
> foreach $grp (sort keys %group) {
> print "$grp $group{$grp}{n}";
> foreach $clmn (sort keys %{ $group{$grp} } ) {
> print " $group{$grp}{$clmn}{sum}";
> }
> print "\n";
> }
Impatience unwittingly ran amuck over hubris in that one. Change the
print statement above to exclude keys that equal 'n'. Otherwise, we
have a null field tacked on to what is printed out due to my capturing
of 'n' at the same level of the data structure in the while loop:
while (<DATA>) {
@temp = split/\s+/;
$group{$temp[0]}{n}++;
for ($i=1; $i<@temp; $i++) {
$group{$temp[0]}{$i}{sum} += $temp[$i];
}
}
foreach $grp (sort keys %group) {
print "$grp $group{$grp}{n}";
foreach $clmn (sort keys %{ $group{$grp} } ) {
unless ($clmn eq 'n') {print " $group{$grp}{$clmn}{sum}";}
}
print "\n";
}
__DATA__
1 2 5 7 7
3 4 5 7 5
1 2 4 5 4
3 4 3 3 5
3 4 5 6 6
2 4 5 6 7
2 5 5 4 4
prints out:
1 2 4 9 12 11
2 2 9 10 10 11
3 3 12 13 16 16
with no null elements tacked on the end.
Patrick Timmins
$monger{Omaha}[0]
Breathlessly awaiting my next reversal on this :)
(Actually, I think that's it, but this could be my hubris talking again)
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 23 Nov 1998 12:55:50 -0600
From: Dan Brian <dan@clockwork.net>
Subject: Re: where are libnet and Digest::MD5
Message-Id: <3659AFB6.4839F251@clockwork.net>
All modules are at CPAN from www.perl.com.
nguyen.van@imvi.bls.com wrote:
> Hi,
>
> I couldn't find these module. Can you guys tell me where it is?
>
> Thanks
> Van Nguyen
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 23 Nov 1998 10:46:36 -0800
From: Casey Feskens <feskencj@plu.edu>
Subject: Win32:FileSecurity: Writing ACL's
Message-Id: <3659AD8C.5B556FD4@plu.edu>
Has anyone had success using Win32:FileSecurity
to set file permissions. I'm just getting started with this,
using the standard scripts listed with the Win32:FileSecurity
documentation (haven't spent a lot of time modifying them yet).
It appears that I can append to the ACL just fine, but I can't
seem to wipe it out and write a new one.
Any suggestions? Does anyone have a working set of Perl
scripts for this that they might let me take a look at?
Also, recommendations for further documentation of this
particular module would be helpful. I'm still pretty new
at this.
Thanks in advance...
--
-------------------------------------------------
Casey Feskens
Associate Lab Manager/Software Support Specialist
Computing and Telecommunication Services
Pacific Lutheran University
Tacoma, WA 98447
Phone: (253) 535-7525
Fax: (253) 536-5099
E-mail: feskencj@plu.edu
-------------------------------------------------
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 4280
**************************************