[22837] in Perl-Users-Digest
Perl-Users Digest, Issue: 5058 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 29 18:05:47 2003
Date: Thu, 29 May 2003 15:05:10 -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 Thu, 29 May 2003 Volume: 10 Number: 5058
Today's topics:
Re: "nice"ing a script on Unix (nospam)@usit.uio(nospam)
Re: "nice"ing a script on Unix <s_grazzini@hotmail.com>
Re: "nice"ing a script on Unix <bernie@rev.net>
Re: a Bayesian intelligent e-mail autoresponder? <sardines@purse-seine.net>
Re: Bioperl? (entropy123)
Re: Bioperl? (Al MacHonahey)
DBI, Error Handling, and accepted programming practices (Rod)
Re: DBI, Error Handling, and accepted programming pract <mbudash@sonic.net>
Re: Display form data in a html format. (Steve)
Filling an array from another array <graham.drabble@lineone.net>
Re: Filling an array from another array <noreply@gunnar.cc>
Re: Filling an array from another array (Andrew Perrin (CLists))
Re: Filling an array from another array <thepoet@nexgo.de>
Re: Filling an array from another array <michael.p.broida@boeing.com>
Re: Form script changes (Steve)
Re: Form script changes (Steve)
Nice'ing again.. <minceme@start.no>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 29 May 2003 20:08:56 +0200
From: Hallvard B Furuseth <h.b.furuseth(nospam)@usit.uio(nospam).no>
Subject: Re: "nice"ing a script on Unix
Message-Id: <HBF.20030529uizi@bombur.uio.no>
Bernard Cosell wrote:
> Does perl include hooks for the unix 'nice(2)' system call?
getpriority, setpriority.
--
Hallvard
------------------------------
Date: Thu, 29 May 2003 18:12:01 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: "nice"ing a script on Unix
Message-Id: <R3sBa.77758$h42.37390@twister.nyc.rr.com>
Bernard Cosell <bernie@rev.net> writes:
> Does perl include hooks for the unix 'nice(2)' system call? perldoc
> didn't show up anything and searching CPAN for 'nice' gets me a
> thousand hits. Tnx..
$ perldoc POSIX
--
Steve
------------------------------
Date: Thu, 29 May 2003 15:18:43 -0400
From: Bernard Cosell <bernie@rev.net>
Subject: Re: "nice"ing a script on Unix
Message-Id: <d1ncdv069gfqkda6ic5n3nejmkc6g66l31@4ax.com>
On Thu, 29 May 2003 14:02:42 -0400, Bernard Cosell <bernie@rev.net>
wrote:
>Does perl include hooks for the unix 'nice(2)' system call? perldoc
>didn't show up anything and searching CPAN for 'nice' gets me a
>thousand hits. Tnx..
Thanks! It is amazing how knowing where to look makes it obvious in
retrospect how I could have found it. after I tried "perldoc -f nice"
and it wasn't there, I wasn't clever enough to notice the
crossreference on the nice(2) man page to setpriority(2) -- which
would have lead me to "perldoc -f setpriority". On the other side of
the coin, I have close to no intuition about the scope and extent of
the goodies buried in 'use POSIX', but plain-old 'nice' is right
there. [too bad none of the 'perldoc' options can/will take a step
beyond the module names. It would've been neat to have been able to
do "perldoc -f nice" and get back POSIX::nice... followed by the
description, no?]
but problem solved, so thanks again!
/Bernie\
------------------------------
Date: Thu, 29 May 2003 21:29:58 +0100
From: Alan Clifford <sardines@purse-seine.net>
Subject: Re: a Bayesian intelligent e-mail autoresponder?
Message-Id: <Pine.LNX.4.53.0305291941530.1181@mundungus.clifford.ac>
On Wed, 27 May 2003, Western Larch wrote:
WL> Relax, dude. Why not take the proposal as a springboard for
WL> further development? No need to get bent out of shape.
WL>
WL> How about this: instead of replying to every apparent spam message,
WL> reply only to the ones which look like they might possibly be non-spam.
WL> So if every message is assigned a score, and the scores above a
WL> threshold are thrown out as spam, then messages near but just above
WL> the threshold would merit a reply.
WL>
I see. I have an autoresponder. I wrote a just-about-working Bayesian
program but am not using it yet. I automatically collect spam and
non-spam using rules other than the statistical program and build a
database from these. I can run the bayesian program on the emails that
bypassed my spam check and were auto responded to.
The output is not very user friendly yet (it was really an exercise to see
if the bayesian theory worked in practice). I have three different
analyses at the moment but will go for the one in curly brackets I think
(see below).
All these messages are spam except one. That one achieved a zero score
which is good (it's the message starting hn.org) although they should know
better and identify their daemon messages as daemons.
As you can see, there isn't very much in the middle and if I'd lowered my
threshold below 0.9, I would have caught another one.
With this, I could significantly reduce my autoresponses.
[alan@mundungus bayes]$ ./analysemailbox ~/mail/IN.zzzz.greylisted
(0) [0] {0} (0.199071) [a 0.199071] {p 0.201462} 1 Check it out man
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 2 FWD: The name says i
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 3 ***LAST CHANCE...WOR
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 4 CONFIDENTIAL BUSI
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 5 CONFIDENTIAL BUSI
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 6 Re: this is really n
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 7 Alan... You are susp
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 8 Alan... You are susp
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 9 Antispamcheck... You
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 10 Can you help me
(1) [1] {1} (0.999996) [a 1.000000] {p 1.000000} 11 Fwd: They sent it to
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 12 I have something for
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 13 =?windows-1252?Q?Pro
(1) [1] {1} (0.999214) [a 0.999214] {p 0.954096} 14
(0) [0] {0} (0.146644) [a 0.146644] {p 0.310145} 15 What happened to you
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 16 You sure will want i
(0) [0] {0} (0.000000) [a 0.000000] {p 0.000000} 17 Lets work this out
(1) [0] {0} (0.958649) [a 0.890656] {p 0.855974} 18 urgent attention req
(0) [0] {0} (0.409742) [a 0.409742] {p 0.409742} 19 Did ya ever notice?
(0) [0] {0} (0.000000) [a 0.000000] {p 0.000000} 20 hn.org Account Delet
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 21 Education and Profes
(0) [1] {1} (0.000000) [a 1.000000] {p 1.000000} 22 VirgiTech June Semin
(1) [1] {1} (0.946552) [a 1.000000] {p 1.000000} 23 no more ebarrestment
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 24 >>>WORK AT HOME...ST
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 25 Lose Weight Now with
(1) [1] {1} (0.999924) [a 1.000000] {p 1.000000} 26 Professional Logo De
(1) [1] {1} (0.999924) [a 1.000000] {p 1.000000} 27 Professional Logo De
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 28 The Blue Pill That W
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 29 Re:FREE h g h, Be Yo
(0) [0] {0} (0.000000) [a 0.000000] {p 0.000000} 30 Supply electric appl
(0) [1] {1} (0.000033) [a 1.000000] {p 1.000000} 31 =?iso-8859-1?Q?The_H
(0) [1] {1} (0.004683) [a 1.000000] {p 1.000000} 32
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 33 DID YOU GET MY MAIL?
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 34 DID YOU GET MY MAIL?
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 35 DID YOU GET MY MAIL?
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 36 Re:1 Month Supply We
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 37 Re:Fit in your Bikin
(1) [1] {1} (1.000000) [a 1.000000] {p 1.000000} 38 =?iso-8859-1?Q?P/T_T
(1) [1] {1} (0.998423) [a 0.999112] {p 0.952582} 39 Cool screensaver
The last one is quite interesting - it is probably a failed virus message
without the attachment as it appears to come from microsoft - so it is
mostly header with a few lines of mime separaters. The analysis of spam
and non-spam tokens is:
0 0.92033 spam token 0.920330 263 169 <iso-8859-1>
0 0.0359421 non spam token 0.003217 0 23 <screensaver>
1 0.272892 spam token 0.909640 99 73 <multipart>
1 0.0743857 non spam token 0.176362 3 104 <cool>
2 0.293727 spam token 0.838057 221 317 <mime>
2 0.195125 non spam token 0.368258 94 1197 <file>
3 0.553908 spam token 0.836651 276 400 <charset=>
3 0.507365 non spam token 0.453383 673 6023 <the>
4 0.82882 spam token 0.824599 494 780 <content-type>
4 0.814878 non spam token 0.476202 673 5495 <is>
5 0.952582 spam token 0.820266 83 135 <attached>
partial result = 0.952582
(Ignore the numbers on the right of the table as they need to be weighted
to mean anything). So iso-8859-1 is used by the naughty people but
screensaver is a good word. This stuff never ceases to surprise me. Note
that I haven't rebuilt my database for sometime so, when I do, screensaver
will have its "spamness" score increased because of this message.
Out of interest, and for comparison, I ran the bayesian checker again my
non-spam archive of 789 messages (I have recently trucated it as it is my
intention to keep only a few months messages for the database). It caught
9 messages of which 5 were actually spam (remember that this spam /
non-spam sorting has no human intervention), two were probably due to
fact that I hadn't updated my rules to match my real spam rules but even
so, they were announcement emails, and TWO were invoices. It is because
of these two false positives that I haven't implemented the bayesian
filter. However, after updating the database from the current archive of
spam and non-spam mail, I didn't get the two false positives.
Oh yes, with the new database based on fewer but more recent emails, the
spam score for "Cool screensaver" email has increased to 0.998889
0 0.891852 spam token 0.891852 111 30 <mime>
0 0.6569 non spam token 0.188422 15 144 <file>
1 0.907534 spam token 0.836769 207 90 <content-type>
1 0.870255 non spam token 0.405964 176 574 <the>
2 0.968206 spam token 0.819500 110 54 <format>
2 0.956307 non spam token 0.418174 188 583 <is>
3 0.988183 spam token 0.792567 12 7 <multipart>
3 0.986253 non spam token 0.461763 97 252 <all>
4 0.995613 spam token 0.759816 44 31 <iso-8859-1>
4 0.99495 non spam token 0.464701 178 457 <in>
5 0.997917 spam token 0.708577 12 11 <attached>
5 0.997645 non spam token 0.469341 125 315 <message>
6 0.99888 spam token 0.677938 51 54 <charset=>
partial result = 0.998880
Alan
( If replying by mail, please note that all "sardines" are canned.
There is also a password autoresponder but, unless this a very
old message, a "tuna" will swim right through. )
------------------------------
Date: 29 May 2003 11:43:07 -0700
From: email_entropy123@yahoo.com (entropy123)
Subject: Re: Bioperl?
Message-Id: <90cdce37.0305291043.f50cc33@posting.google.com>
ctcgag@hotmail.com wrote in message news:<20030529105339.205$rM@newsreader.com>...
> email_entropy123@yahoo.com (entropy123) wrote:
> > Hey all,
> >
> > I'm still trying to figure out how to write a program to detect cycles
> > (ring structures) in Perl.
>
> You seem to be going about it in a fairly schizoid way.
>
Not on purpose, would you be able to suggest a more straightforward route?
Thanks,
entropy
>
> > If there is any chance this was done in
> > BioPerl I'd like to find out.
>
> I'm pretty sure it isn't in BioPerl, at least not in a chemical sense.
>
>
>
> Xho
------------------------------
Date: 29 May 2003 14:03:57 -0700
From: supermanisadork71@yahoo.com (Al MacHonahey)
Subject: Re: Bioperl?
Message-Id: <f48b8b09.0305291303.1939e226@posting.google.com>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<bb4viq$ns9$1@mamenchi.zrz.TU-Berlin.DE>...
> Bertt <dragaoon@sappers.no> wrote in comp.lang.perl.misc:
> > Uri Guttman wrote:
> > >>>>>> "B" == Bertt <dragaoon@sappers.no> writes:
>
> > > >> Abigail,
> > > >>
> > > >> Yes and no. I've not tried the masturbation route so far. The dildoe > > > module >> on CPAN may/may not be sufficient for my needs - right
> > > now I think its >> not....so I decided to see if there is a
> > > 'pleasure' module which I can >> implement.
> > >
> > >> Don't worry too much about abby, she/he/it used to be a real
> > >> helpful person around here before sliding down the abyssful
> > >> trollistic ceaspit ;p
> > >
> > > that last phrase is more like morontchristiansen style. calling abigail a
> > > troll
> > > is a good ans ure way to get the truth across. now who is
> > > the bigger troll abigail or tom christiansen?
> > >
> > >> Really though, I've never seen your previous question answered, and
> > >> it has been a while so there absolutely no harm in asking again in
> > >> a different way.
>
> > >> Don't let adigail push you way either ;p
> > >
> > > and your very helpful answer is? not much perl content here. and
> > > abigail
> > > did discuss graph stuff and modules with the OP. i don't see much
> > > pushing away. you have much to learn and i doubt you will learn it
> >
> > No Abigail did not. She/he/it only offered one line that too had nothing to
> > do with Perl. Please do not try to insert something that is blatently not
> > there.
>
> Seems like you didn't even look at the other threads about the same
> subject. Check your facts.
>
> Annol
No, he was right in that Abigail offered nothing in this post. A
search on google turned up nothing from her on the subject.
------------------------------
Date: 29 May 2003 13:39:32 -0700
From: anothernumber@yahoo.com (Rod)
Subject: DBI, Error Handling, and accepted programming practices
Message-Id: <eef90f9f.0305291239.3c79fc66@posting.google.com>
I have been working on rewriting some CGI's that use DBI to connect to
a mysql database. While working on the project I became curious as to
whether there were any practices I should follow when using the DBI
module. Right now I typically connect to the database when I execute a
query but immediately disconnect afterwards and reconnect again when a
connection to the database is needed. Is this acceptable, should I
strive to keep one connection open through a run of the program, or
does it really not matter as long as I am consistent? Are there any
books or sites that deal with accepted programming practices while
using DBI? I realize that these types of calls do use resources and
that is why I am concerned, the databases is already rather large and
I don't need the thing to be any slower.
The second part of my question deals with something completely
different, error handling. How do most people deal with errors when
writing CGI's? I need to basically print out a detailed message
stating what errors occured (bad input from the user, couldn't connect
to the database, etc) and then I want to quit.
Many times there will be more than one error (the user has bad input
in two fields), I want to address both errors on the page that is
displayed. Once again, what is the accepted method of doing this.
I have code that works now, but I would like to clean it up. I am
still learning, and I would like to avoid aquiring any bad programming
habits.
Thank you,
Rod
------------------------------
Date: Thu, 29 May 2003 20:48:02 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: DBI, Error Handling, and accepted programming practices
Message-Id: <mbudash-EB10CA.13480129052003@typhoon.sonic.net>
In article <eef90f9f.0305291239.3c79fc66@posting.google.com>,
anothernumber@yahoo.com (Rod) wrote:
> I have been working on rewriting some CGI's that use DBI to connect to
> a mysql database. While working on the project I became curious as to
> whether there were any practices I should follow when using the DBI
> module. Right now I typically connect to the database when I execute a
> query but immediately disconnect afterwards and reconnect again when a
> connection to the database is needed. Is this acceptable, should I
> strive to keep one connection open through a run of the program, or
> does it really not matter as long as I am consistent? Are there any
> books or sites that deal with accepted programming practices while
> using DBI? I realize that these types of calls do use resources and
> that is why I am concerned, the databases is already rather large and
> I don't need the thing to be any slower.
don't know about "accepted", but i 'require' in a .pl file the connects
to the db and defines some db access subroutines. one obvious benefit is
the one-stop editing of the connection params (host, user, pass, error
handling options, etc.).
>
> The second part of my question deals with something completely
> different, error handling. How do most people deal with errors when
> writing CGI's? I need to basically print out a detailed message
> stating what errors occured (bad input from the user, couldn't connect
> to the database, etc) and then I want to quit.
> Many times there will be more than one error (the user has bad input
> in two fields), I want to address both errors on the page that is
> displayed. Once again, what is the accepted method of doing this.
>
> I have code that works now, but I would like to clean it up. I am
> still learning, and I would like to avoid aquiring any bad programming
> habits.
once again, don't know about "accepted", but i keep track of errors in
an array. once i'm thru with error-checking, i see if the array has
anything in it - if it does, i 'join' it together for easy reading and
output the very same html form whose input i'm editing, this time with
the errors in red above the form. i've also modified that technique to
have the errors appear next to the offending data, but it's more work.
hth-
--
Michael Budash
------------------------------
Date: 29 May 2003 13:52:38 -0700
From: techadmin@shaw.ca (Steve)
Subject: Re: Display form data in a html format.
Message-Id: <2e27f51a.0305291252.696374e@posting.google.com>
i know for a fact that the code was altered in the cgi script and not
the HTML files which I have still.
Thanks
"Eric J. Roode" <REMOVEsdnCAPS@comcast.net> wrote in message news:<Xns93883E5325380sdn.comcast@216.166.71.239>...
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> techadmin@shaw.ca (Steve) wrote in news:2e27f51a.0305261950.1b083a87
> @posting.google.com:
>
> > I have a web page, an html form, which when I receive in my e-mail
> > client is all text, in fact all the fileds are displyed not just the
> > ones filled. I would like to have the entire html page sent through
> > the email so when printed it will look exactly like the page that was
> > filled out. The forms, when first created worked perfectly, now that
> > we are using them and had to make a few changes, moved the filed from
> > a UNIX server to NT server, they do not e-mail the same way. I
> > remember the person who created tham saying that all they had to was "
> > encase them in 'Brackets'or 'Parenthases' or something of that nature
> > alhtough I am not sure what to put in brackets? I manot sure if they
> > meant the code in the forms.pl file or the code in the html file. can
> > anyone help.
> >
> > Can anyome help
>
> Perhaps you should ask in an HTML or email newsgroup. I don't see anything
> applicable to Perl above.
>
> - --
> Eric
> $_ = reverse sort qw p ekca lre Js reh ts
> p, $/.r, map $_.$", qw e p h tona e; print
>
> -----BEGIN xxx SIGNATURE-----
> Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
>
> iQA/AwUBPtM45mPeouIeTNHoEQK9NQCdHRiIN5tQDLSSMQr4uzwxBtRSLNcAoNXc
> kS+u7dZlw9+e0eMQC9zE1CGB
> =VHnB
> -----END PGP SIGNATURE-----
------------------------------
Date: Thu, 29 May 2003 21:05:40 +0100
From: Graham Drabble <graham.drabble@lineone.net>
Subject: Filling an array from another array
Message-Id: <Xns938AD695C801Cgrahamdrabblelineone@ID-77355.user.dfncis.de>
Hi all,
I'm trying to do this and have been working on it for a while and
haven't even got close to getting code that does what I need.
If I have
@choices = ('a', 'b', 'c')
and
$depth = 3;
then how can I make
@all_possible_choices = ('a a a',
'a a b',
'a a c',
'a b a',
'a b b',
.... all the rest,
'c c c',)
I've tried numerous things using different loops but am getting
nowhere.
--
Graham Drabble
If you're interested in what goes on in other groups or want to find
an interesting group to read then check news.groups.reviews for what
others have to say or contribute a review for others to read.
------------------------------
Date: Thu, 29 May 2003 22:17:16 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Filling an array from another array
Message-Id: <bb5qoo$3qmh3$1@ID-184292.news.dfncis.de>
Graham Drabble wrote:
> If I have
>
> @choices = ('a', 'b', 'c')
> and
> $depth = 3;
>
> then how can I make
>
> @all_possible_choices = ('a a a',
> 'a a b',
> 'a a c',
> 'a b a',
> 'a b b',
> .... all the rest,
> 'c c c',)
>
> I've tried numerous things using different loops but am
> getting nowhere.
Please let us see your best shot so far.
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 29 May 2003 17:09:24 -0400
From: clists@perrin.socsci.unc.edu (Andrew Perrin (CLists))
Subject: Re: Filling an array from another array
Message-Id: <84n0h5xxx7.fsf@perrin.socsci.unc.edu>
Graham Drabble <graham.drabble@lineone.net> writes:
> Hi all,
>
> If I have
>
> @choices = ('a', 'b', 'c')
> and
> $depth = 3;
>
> then how can I make
>
> @all_possible_choices = ('a a a',
> 'a a b',
> 'a a c',
> 'a b a',
> 'a b b',
> .... all the rest,
> 'c c c',)
>
Check out Algorithm::Permute (or any one of several other modules that
do the same thing).
--
----------------------------------------------------------------------
Andrew J Perrin - http://www.unc.edu/~aperrin
Assistant Professor of Sociology, U of North Carolina, Chapel Hill
clists@perrin.socsci.unc.edu * andrew_perrin (at) unc.edu
------------------------------
Date: Thu, 29 May 2003 23:20:17 +0200
From: "Christian Winter" <thepoet@nexgo.de>
Subject: Re: Filling an array from another array
Message-Id: <3ed679b5$0$18810$9b4e6d93@newsread2.arcor-online.net>
"Graham Drabble" <graham.drabble@lineone.net> schrieb:> Hi all,
>
> I'm trying to do this and have been working on it for a while and
> haven't even got close to getting code that does what I need.
Hi,
one simple approach would be to simply do as many
loops as $depth wants, e.g.
------------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
my @choices = ("a","b","c");
my @all_possible_choices;
foreach my $x (0..2) {
foreach my $y (0..2) {
foreach my $z (0..2) {
push @all_possible_choices, "$choices[$x] $choices[$y] $choices[$z]";
}
}
}
print $_."\n" foreach( @all_possible_choices );
---------------------------------------------------------------------
If you want to make a program that fits a variable
number of choices and result depths, take a recursive
approach:
---------------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
my @choices = ("a","b","c");
my $depth = 3;
# Start with an empty string:
my @all_possible_choices = combine( $depth, "" );
print $_."\n" foreach( @all_possible_choices );
sub combine {
my ( $deep, $combination ) = @_;
my @results;
if( $deep > 0 ) {
# Another step to go
foreach( 0..$#choices ) {
# Append every possible item of @choices and call
# combine() to see if there is still some more to be appended:
push @results, combine( $deep-1, join " ",$combination,$choices[$_] );
}
# and return the whole array we got
return @results;
} else {
# Finished, nothing to append, so what we return is
# just the solution combine() got called with
return $combination;
}
}
----------------------------------------------------------------------
HTH
-Christian
------------------------------
Date: Thu, 29 May 2003 21:44:54 GMT
From: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: Filling an array from another array
Message-Id: <3ED67F56.30D5AB8F@boeing.com>
Graham Drabble wrote:
>
> Hi all,
>
> I'm trying to do this and have been working on it for a while and
> haven't even got close to getting code that does what I need.
>
> If I have
>
> @choices = ('a', 'b', 'c')
> and
> $depth = 3;
>
> then how can I make
>
> @all_possible_choices = ('a a a',
> 'a a b',
> 'a a c',
> 'a b a',
> 'a b b',
> .... all the rest,
> 'c c c',)
>
> I've tried numerous things using different loops but am getting
> nowhere.
There may very well be more "elegant" Perl methods,
but I would use simple nested loops:
UNTESTED AIR-CODE:
foreach $val_1 (@choices)
{
foreach $val_2 (@choices)
{
foreach $val_3 (@choices)
{
push @all_possible_choices, "$val_1 $val_2 $val_3";
}
}
}
The only thing I'm not sure of about the above UNTESTED
code is whether doing three nested "foreach" loops over
the same array has any "BAD" side-effects, but I can't
think of any. You'll find out if you test it (as I un-
fortunately don't have the time at the moment).
Mike
------------------------------
Date: 29 May 2003 13:51:12 -0700
From: techadmin@shaw.ca (Steve)
Subject: Re: Form script changes
Message-Id: <2e27f51a.0305291251.4cd7034e@posting.google.com>
John Strauss <john.thetenant-s@moving-picture.com> wrote in message news:<20030529170640.27025d13.john.thetenant-s@moving-picture.com>...
> On 29 May 2003 08:39:03 -0700
> techadmin@shaw.ca (Steve) wrote:
> >
> > I have a simple perl script running to process form input (bnbform
> > version 4.0?)(The forms are all html). Right now the form returns all
> > the values that are available on the form in the form of a list, a=,
> > b=, c=. If you enter into the form the value for a as ABC then you
> > reveive, a=abc,b=,c= etc. I would like to recode it so that the only
> > values returned are those input values used. so in fact b= and c=,
> > would not show in the e-amil as there was no input value assigned. I
> > hope this all makes sence.
> > My knowledge of perl is limited to none but follow instruction well.
>
> replace
> @pairs=split(/&/,$temp);
>
> with
> @pairs=grep(/=.+/,split(/&/,$temp));
>
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drop the .thetenant to get me via mail
Thanks, for the fast response.
What I am understanding is that as long as I don't return a value of
'0' for a check box then I should be ok.
What about a '0' in a text box? although I don't think that would
happen.
Could you please give a quick explanation of what each line is doing
this way I can better understand what I am typing.
Thanks for all your help. Steve
------------------------------
Date: 29 May 2003 14:36:37 -0700
From: techadmin@shaw.ca (Steve)
Subject: Re: Form script changes
Message-Id: <2e27f51a.0305291336.5aa45eb2@posting.google.com>
Sorry but after making both of these changes it does not do as
intended i still receive all entries filled or not.
Any ideas? do you wish to see the code? It big as you know.
Thanks, Steve
John Strauss <john.thetenant-s@moving-picture.com> wrote in message news:<20030529170640.27025d13.john.thetenant-s@moving-picture.com>...
> On 29 May 2003 08:39:03 -0700
> techadmin@shaw.ca (Steve) wrote:
> >
> > I have a simple perl script running to process form input (bnbform
> > version 4.0?)(The forms are all html). Right now the form returns all
> > the values that are available on the form in the form of a list, a=,
> > b=, c=. If you enter into the form the value for a as ABC then you
> > reveive, a=abc,b=,c= etc. I would like to recode it so that the only
> > values returned are those input values used. so in fact b= and c=,
> > would not show in the e-amil as there was no input value assigned. I
> > hope this all makes sence.
> > My knowledge of perl is limited to none but follow instruction well.
>
> replace
> @pairs=split(/&/,$temp);
>
> with
> @pairs=grep(/=.+/,split(/&/,$temp));
>
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drop the .thetenant to get me via mail
------------------------------
Date: Thu, 29 May 2003 21:42:00 +0000 (UTC)
From: Vlad Tepes <minceme@start.no>
Subject: Nice'ing again..
Message-Id: <bb5ur7$cm6$1@troll.powertech.no>
Hi,
Reading the other post about altering priorities on scripts, I thought
I'd try it out. I was expecting to make the script run slower when
giving a high value with setpriority, but it seems not to make any
difference.
Maybe someone could explain how and when to use these functions?
(I'm using Redhat 7.2, perl 5.8.0)
Here's my test script:
#!/usr/bin/perl -w
use strict;
use Benchmark qw( :all );
my $count = 10;
timethis( $count, \&count_to_a_million );
setpriority( 0, 0, 19 ) or die;
timethis( $count, \&count_to_a_million );
sub count_to_a_million {
my $i = 0;
do {
$i++;
} until $i > 1e6;
}
__END__
--
(,_ ,_, _,)
/|\`\._( )_./'/|\
· · \/ L /\ D · ·
/__|.-'`-\_/-`'-.|__\
` " `
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 5058
***************************************