[13152] in Perl-Users-Digest
Perl-Users Digest, Issue: 562 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 17 02:07:21 1999
Date: Mon, 16 Aug 1999 23:05:34 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 16 Aug 1999 Volume: 9 Number: 562
Today's topics:
Re: Array, Subroutine question (Ronald J Kimball)
Can I get help getting off the ground w/GD? (Ct60)
Re: Can I get help getting off the ground w/GD? (elephant)
Re: cannot write description to eventlog (elephant)
Re: Creating hotlinks out of plain URLs in Perl. (Abigail)
Re: HARASSMENT -- Monthly Autoemail <nobody@wants.spam>
Re: HARASSMENT -- Monthly Autoemail (Dave Salovesh)
Re: HARASSMENT -- Monthly Autoemail (Ronald J Kimball)
Re: HARASSMENT -- Monthly Autoemail (Ronald J Kimball)
Matching more than one item on a line?? <bellj@nospamnycap.rr.com>
Re: module suggestion- Net::SNTP (William Herrera)
Re: Newbie question: Creating a NT login script in Perl (elephant)
Re: Pattern matching on command line (Ronald J Kimball)
Perl on PalmV yet? (Danny Aldham)
Re: Referencing Questions (Ronald J Kimball)
select(STDOUT) and $| <callen@boxcar.driver8.org>
Re: sorting arrays (Ronald J Kimball)
Re: statistical sorts (Ronald J Kimball)
Re: unCRAP (was Re: Perl Services) <elaine@chaos.wustl.edu>
Re: Why It's Cool To Make Fun Of Bad Code <monty@primenet.com>
Re: Writing lines to file twice or more (newbie questio (Ronald J Kimball)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 17 Aug 1999 00:22:58 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Array, Subroutine question
Message-Id: <1dwnmun.15dr7v1dp3vupN@p183.tc2.state.ma.tiac.com>
Bart Lateur <bart.lateur@skynet.be> wrote:
> soccerreferee@hotmail.com wrote:
>
> > @friends = qw(Peter Paul Mary Jim Tim);
> > ($this, $that) = shift2(@friends);
> >
> > sub shift2 (\@) {
> > return splice(@{$_[0]}, 0, 2);
> > }
> >
> >I have tried to run the code, but $this and $that come back as null,
> >and @friends remains unchanged.
>
> Euh... Shouldn't you switch the order? I.e. define the sub *first*, and
> put the sub call below that.
Did you try it both ways?
Doesn't matter, because the subroutine is being called with parentheses
around the arguments, which tells perl that it is, indeed, a subroutine
call. It happily assumes that the subroutine will be declared later in
the compilation process. If it isn't, you get a runtime error.
The only problem occurs when the subroutine is called with neither an
ampersand nor parentheses around the arguments. In that case, the
subroutine declaration must be compiled first.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 17 Aug 1999 04:40:48 GMT
From: ct60@aol.com (Ct60)
Subject: Can I get help getting off the ground w/GD?
Message-Id: <19990817004048.07355.00000410@ng-fv1.aol.com>
Perhaps if laziness is indeed one of the great virtues of programming, I can be
excused for asking this question.
I have just spent the past couple of hours trying to get the GD.pm module to
work. It seems to require being compiled. I have only an old Turbo C++ DOS
compiler - is that enough to get the job done? Perhaps I could get a little
more guidance than the cryptic instruction that come w/ the module. Thank you
for your consideration. ct60@AOL.com (Christopher Tauss)
------------------------------
Date: Tue, 17 Aug 1999 15:26:49 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Can I get help getting off the ground w/GD?
Message-Id: <MPG.12239da12764a7f0989c3a@news-server>
Ct60 writes ..
>Perhaps if laziness is indeed one of the great virtues of programming, I can be
>excused for asking this question.
>I have just spent the past couple of hours trying to get the GD.pm module to
>work. It seems to require being compiled. I have only an old Turbo C++ DOS
>compiler - is that enough to get the job done? Perhaps I could get a little
>more guidance than the cryptic instruction that come w/ the module. Thank you
>for your consideration. ct60@AOL.com (Christopher Tauss)
ok .. you've provided no information about your OS or Perl version or
anything really .. I suppose we can glean that you're using some form of
DOS .. so I'll just assume that you're using some Win32 operating system
on which you have a working version of ActiveState's port of perl
assuming that - from a command prompt type the following
ppm install GD
and your ActiveState overlord will download and install the GD.pm module
onto your machine for you .. QED
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Tue, 17 Aug 1999 15:10:43 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: cannot write description to eventlog
Message-Id: <MPG.122399e2a428ab6c989c38@news-server>
da_minch@my-deja.com writes ..
>below is the code that i am making use of for this portion of the app:
>
>########
>use Win32::EventLog;
>
>$handle = Win32::EventLog->new("Application", $ENV{ComputerName});
>
>msg("im not feeling very intelligent");
>
>
>sub msg
>{
> my $h = {'EventType' => EVENTLOG_ERROR_TYPE,
> 'Source' => "whatever",
> 'Computer' => "boxname",
> 'EventCategory' => "General",
> 'EventID' => 0,
> 'Data' => @_,
> 'Strings' => @_,
> };
> $handle->Report($h);
>}
I have no idea where you're reading your documentation for this module
from .. I couldn't find any in the module itself .. but the
documentation that you're using is clearly wrong - because your hash
keys are all screwy .. and you seem to have a warped idea of what the
first parameter to 'new' is (it's NOT the section of the event log)
you also need to read up on what an array returns when you evaluate it
in a scalar context - because the @_ above probably isn't doing what you
expect .. for more information - from a command prompt type
perldoc perldata
I did some digging through the Report procedure in EventLog.pm itself ..
which led me to the following code - which works (NB: I didn't use a sub
because it seems pointless here .. but if you continue to use that sub
then you'll have to read through the perldata documentation first to get
the right idea of how to use the @_ array - you may also want to check
out perlsub for examples)
also .. I should say that I have no idea how to interract with the event
log having never done it before .. it seems like it's expecting a
callback to retrieve some event information .. but I really don't know -
anyway .. the following gets the string in there
#!perl -w
use strict;
use Win32::EventLog;
my $catNum = 0; # no idea what an event Category is
my $evId = 0; # no idea what an event Id is either
my $hndl = Win32::EventLog->new( 'My Testing Application'
, $ENV{ ComputerName}
);
my $h = { Category => $catNum
, EventType = EVENTLOG_ERROR_TYPE
, EventID => $evId
, Data => ''
, Strings => "\r\nSome information here"
};
$hndl->Report( $h);
__END__
this produces an event in the Application event log with the following
text
"The description for Event ID ( 0 ) in Source ( Testing ) could not be
found. It contains the following insertion string(s):
Some information here."
optionally - you can include some data in the Data value .. this can be
binary and will be included with the event entry
HTH
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: 17 Aug 1999 00:56:15 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Creating hotlinks out of plain URLs in Perl.
Message-Id: <slrn7rhuds.9e1.abigail@alexandra.delanet.com>
Sunfox (sunfox@sunwerx.com) wrote on MMCLXXVII September MCMXCIII in
<URL:news:wO4u3.112288$U42.165543@news1.rdc1.bc.home.com>:
##
## I think I've figured it out. It won't work if there are "special" characters
## in the URL, such as http://www.domain.com/~user/index.html - only the text
## before ~ will be linked. Same with
## http://www.domain.com/index.html#linktext - only the part before # is used.
## This is a bit beyond me; is it possible to include ~ and # and ? in the list
## of acceptable characters?
Well, the ultimate goal was RFC compliance. By the time the program was
written, RFC 1738 was the current standard. That standard was sane and
did not allow `~' as a character. Hence, my regex will not allow `~' as a
character. RFC 2396 however, allows `~'. A trivial fix allows `~' as well;
in the code I posted that generates the regex, take `~' out of the $national
character equivalence class, and add it to $extra.
As for `#', no, there's no way to allow that. In the line:
http://www.domain.com/index.html#linktext
the URI (URL) is:
http://www.domain.com/index.html
and
linktext
is a fragment identifier. `#' is the character that separates the URI
from its fragment identifier. Both RFC 1738 and RFC 2396 forbid the
use of `#' in URIs for this reason. See section 4 of RFC 2396.
One of these days, when people stop posting to clpmisc, I'll have the time
to update the regex to RFC 2396. Some other URL schemes got an updated
RFC as well. And most of all, the regex generator cheats when creating
the LDAP url part; it's way too lax. That's because it was written in
the 5.004 days. With Ilya's new stuff, it's hopefully possible to make
a regex that actually follows the grammer of RFC 1558.
Abigail
--
perl -wle\$_=\<\<EOT\;y/\\n/\ /\;print\; -eJust -eanother -ePerl -eHacker -eEOT
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Tue, 17 Aug 1999 00:04:40 -0400
From: "Curly++" <nobody@wants.spam>
Subject: Re: HARASSMENT -- Monthly Autoemail
Message-Id: <7pamu4$pm9$1@news2.tor.accglobal.net>
Jerome O'Neil <jeromeo@atrieva.com> wrote in message news:7p1h6r$aen$1@brokaw.wa.com...
> In article <37B43687.B0525875@tiac.net>,
> Uriel Wittenberg <urielw@tiac.net> writes:
> > This comp.infosystems.www.authoring.html participant appears to have
> > opted to openly harass me...
>
> For excessive whining: (thats tough to do on c.l.p.m)
Whining, bickering and complaining seem to be full-
time preoccupations in this particular corner of the
internet. Perhaps everyone should take a few minutes
to re-read
http://www.cs.indiana.edu/docproject/zen/zen-1.0_6.html#SEC31
especially the section titled "If You're Unhappy".
For further reading, please use your favorite search
engine to look up "beginner's guide to the internet"
and maybe even include the keyword "netiquette". You
will find a lot of very interesting reading.
BTW, "Zen" at this site is in pretty bad shape. If
anyone has a pointer to a less dog-eared copy, I'd
appreciate a URL.
--
Oisin "pretending everyone read it already" Curtin
I HAVE MAIL: curlyplusplus@NOSPAM@crosswinds.net
<sigh> Do the usual cleanup.
Coming soon: http://www.crosswinds.net/~curlyplusplus
------------------------------
Date: Tue, 17 Aug 1999 04:09:02 GMT
From: darsal@erols.com (Dave Salovesh)
Subject: Re: HARASSMENT -- Monthly Autoemail
Message-Id: <37b8dedf.30141037@news.erols.com>
In article <7p7mt7$em0$1@news.NERO.NET>,
stanley@skyking.OCE.ORST.EDU (John Stanley) opined:
>Someone who speaks the truth. Posting to USENET does not solicit email.
>If it did, then every UCE you get that starts with "saw your posting in
>USENET, thought this might be of interest" is something you solicited.
I'm beginning to understand - I am certain you believe what you know to
be true.
But really, where did that belief come from?
Please, point me to a netiquette guide, your AUP, your TOS, a FAQ,
something, just one well distributed source which says that posting to
Usenet does not solicit, does not permit, email replies - just so I can
understand your point of view. If it's something that "everyone" knows
because it's published somewhere the same "everyone" goes, I've never
been there and I'd like to go - It might help me clear up some
misunderstandings I have.
But every source I've ever read with an opinion on the subject
explicitly suggests that there are situations where replies to Usenet
posts should be sent via email.
If it's simply your view about what you like to see, then that's fine.
Put it in your .sig, use a sub-address for your Usenet posts, and filter
out anything that comes to that address. Simple enough for most
situations...
As to your point about UCE, IMNSHO UCE is not objectionable just because
it's U, or just because it's C, but because the U and the C come
together. There's a gray area in there, where motives and other factors
must be considered, but as long as it's a personal contact in response
to a Usenet post, it doesn't deserve to be called UCE.
------------------------------
Date: Tue, 17 Aug 1999 00:22:50 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: HARASSMENT -- Monthly Autoemail
Message-Id: <1dwnjf0.uynkxu15zj8eoN@p183.tc2.state.ma.tiac.com>
I R A Darth Aggie <fl_aggie@thepentagon.com> wrote:
> On Mon, 16 Aug 1999 11:15:17 +0100, Ian Clarke <I.Clarke@strs.co.uk>, in
> <37B7E4B5.6D727879@strs.co.uk> wrote:
>
> + Tom should grow up, and those defending him should show some backbone.
>
> Backbone? I should have done this days ago. GoAT.
>
> *plonk*
>
If that's the way you feel, please *plonk* me too. I agree with Ian
that Tom should grow up.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Tue, 17 Aug 1999 00:22:51 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: HARASSMENT -- Monthly Autoemail
Message-Id: <1dwnjhi.1ciurfm19u2zr4N@p183.tc2.state.ma.tiac.com>
I R A Darth Aggie <fl_aggie@thepentagon.com> wrote:
> James - oh, and don't email me...
I thought you had just put considerable effort into arguing that you had
no right to make that statement on USENET.
How curious.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Tue, 17 Aug 1999 00:52:24 -0400
From: "Jim Bell" <bellj@nospamnycap.rr.com>
Subject: Matching more than one item on a line??
Message-Id: <kT5u3.1677$O02.40739@typhoon.nyroc.rr.com>
Hi, I'm non-programmer who's trying to get started with Perl and has run
into a head-scratching dead-end with my first practical project. I've read
through the appropriate sections of my Perl book (no, I don't have the
O'Reilly bibles, but they're next on my shopping list) and looked through as
much material online as I could before posting here, but either missed the
answer or didn't recognize it when it was in front of me. I'm hoping
someone can give me a gentle shove in the right direction!
All I'm trying to do is to read through one file line by line, identifying
all instances of a particular text string. When found, I want to write the
text string to another file. This code below works, BUT if a line contains
more than one instance of the searched-for string, only the first instance
is identified. The identified string begins and ends properly; it's not
including all characters to the end of the line--so that's not the problem.
One passage in the book seems to suggest that this is how matches work
(always stop at first match), but if so I haven't seen anything that
explains the best way to compensate. I'm guessing the problem is that
after matching the first string, my code is immediately moving to process
the next line; but don't know if I need to change the search expression or
modify the looping process. Again, thanks for any input!
SAMPLE PROG===
open (INFILE, 'c:\mydocu~1\session.txt') or die "Can't read SESSION.TXT:
$!\n";
open (OUTFILE, '>c:\mydocu~1\test.txt') or die "Can't open file: $!\n";
while (<INFILE>) {
if (/((A|S)\.\d{1,5}\-?\w{0,1})/) {
print OUTFILE "$1\n";
}
}
close OUTFILE;
SAMPLE DATA===
Asd Fsd sdfsdf A.100 sd sadfasd fsad #returns A.100, works fine
Sdsdf dfsd sd S.223-B sdfsd sadfsdf d #returns S.223-B, works fine
A.323 sdasd sadfsadfasd fasd fsda fsad #returns A.323, works fine
sdfasdf S.3234-A sdfsdf S.200 sdfd #returns S.3234-A, but not S.200
------------------------------
Date: Tue, 17 Aug 1999 05:35:27 GMT
From: posting.account@lynxview.com (William Herrera)
Subject: Re: module suggestion- Net::SNTP
Message-Id: <37b8f3d5.139610642@news.rmi.net>
On 16 Aug 1999 08:34:28 -0600, ljp <ljp@209.204.251.8> wrote:
>I would like to suggest a module, Net::SNTP, if it doesn't exist already, or
>perhaps this is such a simple task, as to not warrant a module.
>Since I am not yet, nor will ever be, a perl guru, I am suggesting this to
>those in the perl-know, in that there may be an easy way to change
>one's date according to SNTP.
how about Net::NetTime or maybe someting like it?
http://www.dux.ru/guest/fno/perl/NetTime/Net_NetTime_0.02.zip
---
The above from: address is spamblocked. Use wherrera (at) lynxview (dot) com for the reply address.
------------------------------
Date: Tue, 17 Aug 1999 15:18:08 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Newbie question: Creating a NT login script in Perl
Message-Id: <MPG.12239b96173c6c6989c39@news-server>
lcook@carolina.rr.com writes ..
>What is the easiest way to create an NT login script where if the user
>belongs to a particular local group, the login script will map a drive
>for them?
definitely with a text editor .. and don't listen to anyone who says
otherwise !!
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Tue, 17 Aug 1999 00:22:53 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Pattern matching on command line
Message-Id: <1dwnkoq.cffko98r311fN@p183.tc2.state.ma.tiac.com>
<tyeung@netscape.net> wrote:
> on the command line:
> perl program m/word/i < inputfile
>
> in the program:
> if ($string =~ @ARGV)
>
> instead of
>
> on the command line:
> perl program word < inputfile
>
> in the program:
> if ($string =~ m/@ARGV/i)
>
No, you cannot do that, unless you use eval. However, you can do this
instead:
perl program '(?i)word' < inputfile
which will have the desired effect. Refer to perlre for more info.
--
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
perl -se'print sort grep/(?imsx)\s/, keys%main::
' -- -is -' Just' -' another ' -'Perl ' -'hacker
' http://www.tiac.net/users/chipmunk/ [rjk@linguist.dartmouth.edu]
------------------------------
Date: 17 Aug 1999 04:12:35 GMT
From: danny@lennon.postino.com (Danny Aldham)
Subject: Perl on PalmV yet?
Message-Id: <7panfj$up3$1@lennon.postino.com>
X-Newsreader: TIN [version 1.2 PL2]
My employer just gave me a neat new Palm Pilot V. So of course my
first inclination is to put something useful on it. So is there a
perl interpreter compiled for the Palm Pilot yet? (Only 1/2 kidding)
--
Danny Aldham Providing Certified Internetworking Solutions to Business
www.postino.com E-Mail, Web Servers, Mail Lists, Web Databases, SQL & Perl
------------------------------
Date: Tue, 17 Aug 1999 00:22:54 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Referencing Questions
Message-Id: <1dwnlir.13wxi4g1bwzqj9N@p183.tc2.state.ma.tiac.com>
Matthew Forder <matthew_j_forder@notes.seagate.com> wrote:
> In the main code of the perl program, I create a instance of my object,
> and open the socket. Now I need to use the FH to listen and send, I
> think I should be able to do this:
>
> print $instance->{'filehandle'} "socket message\n";
> $reply <$instance->{'filehandle'}>;
>
> but, perl doesn't like it. I have found (through trial and error) that I
> send using:
>
> print { $instance->{'filehandle'} } "socket message\n";
>
> but this doesn't work when trying to read.
>
> If anyone can help, or at least nudge me in the right direction, I would
> be very greatful.
perlop explains that within angle brackets <>, a filehandle must be
either a bareword or a simple scalar. Anything else means the <> is
treated as the globbing operator.
Solution: When you want to read from the filehandle with the <>
operator, copy it to a simple scalar variable first.
my $fh = $instance->{filehandle};
$input = <$fh>;
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 17 Aug 1999 04:35:11 GMT
From: Christopher Allen <callen@boxcar.driver8.org>
Subject: select(STDOUT) and $|
Message-Id: <7paopv$2g9o$1@news1.spacestar.net>
Greetings:
Reading from /dev/ttyp* comes up with an interesting problem to me:
this bit of code works but doesn't:
while (<check>) {
select ($tiki);$| = 1;
print $tiki "$_ \n";
}
where check is /dev/ttyp1
where $tiki is STDOUT
I thought okay seems good should print whatever I type on ttyp1
Unfortunately nothing prints, but when I do this from shell:
strace -p 1241 (1241 is the perl process I had started)
I get what I want:
root@vermont /root]# strace -p 1242
read(3, "\r", 4096) = 1
read(3, "w", 4096) = 1
read(3, "l", 4096) = 1
read(3, "s", 4096) = 1
---
I get the feeling the logic of what/how I am doing this is not quite right,
not the code. Any one have any ideas?
Thanks
callen
------------------------------
Date: Tue, 17 Aug 1999 00:22:55 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: sorting arrays
Message-Id: <1dwnlwc.6uoeae1jsz2kbN@p183.tc2.state.ma.tiac.com>
Larry Rosler <lr@hpl.hp.com> wrote:
> In article <37B8917B.67B78B75@cisco.REMOVETHIS.com> on Mon, 16 Aug 1999
> 15:32:27 -0700, Makarand Kulkarni <makkulka@cisco.REMOVETHIS.com>
> says...
> > mikej wrote:
> >
> > > sub alphabetically {$a cmp $b}
> >
> > Sort sorts lexically by default. You do not need a alphabetically ()
> > function
> > to do this. For more information lookup perldoc -f sort.
>
> Yes, that's true. But as it doesn't change the behavior of the program,
> it is irrelevant to solving the reported problem.
>
> Which I can't solve either, because it all seems legit to me!
Odd. It worked fine for me.
client.log:
second
first
third
output:
Content-type:text/html
<html><head><title>query results</title></head>
<body bgcolor= "#FFFFFF">
sorted list: first
second
third
<BR>
</body></html>
Correct output in perl5.005 and perl5.004.
--
chipmunk (Ronald J Kimball) <rjk@linguist.dartmouth.edu>
perl -e 'print map chop, sort split shift, reverse shift
' 'j_' 'e._jP;_jr/_je=_jk{_jn*_j &_j :_j @_jr}_ja)_js$_j
~_jh]_jt,_jo+_jJ"_jr>_ju#_jt%_jl?_ja^_jc`_jh-_je|' -rjk-
------------------------------
Date: Tue, 17 Aug 1999 00:22:57 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: statistical sorts
Message-Id: <1dwnm40.65wz75rhc1udN@p183.tc2.state.ma.tiac.com>
David Cassell <cassell@mail.cor.epa.gov> wrote:
> Marc Grober wrote:
> >
> > I am looking for a way to sort a population into arbitrarily sized
> > groups so that the distribuition of a characteristic in the full
> > population is the same as in the sample groups. I have looked at CPAN's
> > stat modules and was really looking for somethingat a higher level in
> > that I am sure there must be code like this already in use.
>
> Excuse me? I'm sorry, but I really don't know what you're
> asking. Distributions of population parameters don't have
> much to do with sorting. Perl does have lots of ways to
> sort, and a number of modules on statistical stuff. But I
> don't know what you're after.
I think the original poster means something like 'partition' rather than
'sort. He wants to divide the population into groups, so that each of
the groups has the same distribution of a particular characteristic as
the full population.
That shouldn't be too hard. For each group, add N elements for each
possible value of the characteristic, where N is the distribution of
that value in the full population, multiplied by the desired size of the
group being created.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Tue, 17 Aug 1999 01:24:24 -0400
From: Elaine -HFB- Ashton <elaine@chaos.wustl.edu>
Subject: Re: unCRAP (was Re: Perl Services)
Message-Id: <37B8F200.148F94E1@chaos.wustl.edu>
brian d foy wrote:
> i remember the first time i talked to elaine in person - it was at a
> Perl Mongers dinner at last year's Perl Conference. she had a beer in
> each hand and was alternately drinking from each. there were clear
> "don't get in my way" vibes ;)
In a room with 50+ geeky guys I was on a mission, a lady must have her
priorities....;) mmm...beer. Lunch is an entirely different realm though
as I'll gladly share my beer or even buy another, but I'll never share
my lunch :)
e.
------------------------------
Date: 17 Aug 1999 05:48:51 GMT
From: Jim Monty <monty@primenet.com>
Subject: Re: Why It's Cool To Make Fun Of Bad Code
Message-Id: <7pat43$cuc$1@nnrp02.primenet.com>
Uri Guttman <uri@sysarch.com> wrote:
> i have never used Text::Wrap but i can understand your frustration.
Thank you.
> a quick glance at the code of the latest version shows that the die on
> long word problem is fixed (it can be enabled/disabled). and the tabs
> stuff is caused by the use of Text::Tabs(expand,unexpand). if your first
> 2 arguments to Text::Wrap (initial_tab, subsequent_tab) are '', you
> should not get any tabs in your output.
Unfortunately, it was *because* I needed to indent the second and
subsequent lines of reformatted text that I was using Text::Wrap.
> the code expands the tabs so it
> can get the line length and then it unexpands them (possibly inserting
> tabs) regardless of whether there were actual tabs in the those
> args. this is not good fr you and i would write the authors and tell
> them so. it would be easy to skip the actual unexpand if there wer no
> tabs in the args.
My workaround (which, by the way, I am *not* pleased with) was to
use Text::Tabs::unexpand on the wrapped text. I used *two* modules
where, frankly, I would have prefered to use none. I know all about
code reuse and not reinventing the wheel; if I didn't, I might have
written the script in awk. But I don't think I should have had to
use two modules to accomplish what I'm pretty sure can be done in
a single, skillfully-written s/// operation. (I wasn't doing general
reformatting of multiple, variable-length lines of text. I was
simply breaking single lines of text that I *knew* exceeded some
length limitation into two or more lines that did not exceed that
limitation, and were also indented.)
> now provide a patch to Text::Wrap to make it work better for
> yourself and the rest of us.
I do appreciate the spirit in which you make this suggestion: Perl
is open source software that is freely supported (and supported
for free) by its user community. But you must have read my comment
that this was the first time I had ever used a module in a Perl
script, and you cannot have failed to grasp the gist of my rant.
Do you really want *me* to patch Text::Wrap? I'm not one of the
few Perl experts who, like you, are qualified to maintain the
language and its peripherals. I'm one of the (usually) silent
majority who just use Perl (or awk, or Korn shell, or Visual Basic,
or whatever) to help keep themselves gainfully employed, at least
until this damn Information Age blows over.
--
Jim Monty
monty@primenet.com
Tempe, Arizona USA
------------------------------
Date: Tue, 17 Aug 1999 00:23:00 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Writing lines to file twice or more (newbie question)
Message-Id: <1dwnnao.1w82npxkorj9hN@p183.tc2.state.ma.tiac.com>
<zchon@my-deja.com> wrote:
> @mylist = split /.{0,0}/, $text;
Ah, that's a very odd regular expression. You want to match at least
zero of any character, and at most zero of any character? Rather
redundant.
Try this instead:
@mylist = split //, $text;
[As an argument to split, // matches the null string. Anywhere else, it
matches the regex which was last matched successfully in this scope.]
> FORMATTING CODE
> FORMATTING CODE
> (simply moving characters from @mylist to different positions in
> @newlist)
I wonder if the problem is there. Perhaps you are duplicating
characters during this step, which leads to you getting repeated output.
> $textout = join("",@newlist);
> printf(OUTFILE "%s", $textout);
> printf(OUTFILE "\n");
> $textout = " ";
This is a verbose way of saying:
print OUTFILE @newlist;
$textout = " ";
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
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 562
*************************************