[24719] in Perl-Users-Digest
Perl-Users Digest, Issue: 6874 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 17 09:06:23 2004
Date: Tue, 17 Aug 2004 06:05:09 -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 Tue, 17 Aug 2004 Volume: 10 Number: 6874
Today's topics:
Re: cpan update: 106 installed modules have no parseabl (Anno Siegel)
Re: Documentation for PDF::API2 <wfsp@removeyahoo.com>
Re: Earthquake forecasting program Aug. 16, 2004 (Oriel36)
Re: has anybody write bioinformatics programme with per <no_thanks@bms.umist.ac.uk>
Re: has anybody write bioinformatics programme with per <ithinkiam@gmail.com>
Re: How to turn a number into graphics? <bigiain@mightymedia.com.au>
Re: How to turn a number into graphics? <Greg@zorlord.karoo.co.uk>
Re: How to turn a number into graphics? <noreply@gunnar.cc>
Re: Materializing an indirect sort using only swap (Anno Siegel)
Re: Materializing an indirect sort using only swap (Anno Siegel)
Re: Module to filter HTML (Jim Keenan)
Operator for presence of value in list? (Martin Mrazek)
Re: Operator for presence of value in list? <noreply@gunnar.cc>
Re: Operator for presence of value in list? <bernard.el-haginDODGE_THIS@lido-tech.net>
Re: Operator for presence of value in list? <noreply@gunnar.cc>
Re: Operator for presence of value in list? <bernard.el-haginDODGE_THIS@lido-tech.net>
Re: Operator for presence of value in list? <noreply@gunnar.cc>
Re: Parsing a text file into an array (Anno Siegel)
Re: Placeholder in an sql query <ebohlman@omsdev.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 17 Aug 2004 10:24:17 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: cpan update: 106 installed modules have no parseable version number
Message-Id: <cfsmch$9r1$2@mamenchi.zrz.TU-Berlin.DE>
Steve Kelem <steve@kelem.net> wrote in comp.lang.perl.misc:
> When I run CPAN.pm and type the option "r" (reinstall recommendations),
> I get the message
>
> 106 installed modules have no parseable version number
>
> Why so many modules without version numbers?
Ask the authors. There is no enforcement to have a version number,
so some modules don't have one.
> CPAN.pm has made module maintenance SOOOOOO easy, yet some modules can't
> be easily updated without parsable version numbers.
It's a question of quality. Before you install a module, check if
it has a version number. If it doesn't, think twice.
Anno
------------------------------
Date: Tue, 17 Aug 2004 07:42:43 +0000 (UTC)
From: "wfsp" <wfsp@removeyahoo.com>
Subject: Re: Documentation for PDF::API2
Message-Id: <cfsctj$cjr$1@sparta.btinternet.com>
"Shawn Corey" <shawn.corey@sympatico.ca> wrote in message
news:aN3Uc.5487$Tr.375881@news20.bellglobal.com...
> Hi,
>
> Does anyone know good on-line documentation for PDF::API2? I checked out
> http://cpan.uwinnipeg.ca/htdocs/PDF-API2/ but it's just the same old
> pathetic PODs that tell you nothing about how to use it. Is there
> anything better?
>
> I want to generate PDFs with text that changes. So I need to determine
> the width of the text so that it won't go outside my margins; the
> equivalent of Font::AFM. But apparently Adobe does not publishes its AFM
> files any more.
>
> Thanks.
>
http://www.printaform.com.au/clients/pdfapi2/
------------------------------
Date: 17 Aug 2004 06:02:04 -0700
From: geraldkelleher@hotmail.com (Oriel36)
Subject: Re: Earthquake forecasting program Aug. 16, 2004
Message-Id: <273f8e06.0408170318.1611ffb5@posting.google.com>
"edgrsprj" <edgrsprj@ix.netcom.com> wrote in message news:<0f1Uc.23551$nx2.17009@newsread2.news.atl.earthlink.net>...
> August 16, 2004 Posted to sci.geo.earthquakes and other Newsgroups
>
> Newsgroup Readers: I recommend that you send copies of this report to any
> government officials and researchers that you know who are interested in
> earthquake forecasting science.
>
> The information in this report represents expressions of personal opinion.
>
> This is an introductory report regarding a Perl language earthquake
> forecasting computer program which is now generating good results. I
> personally believe that the program has the potential to enable us to
> accurately forecast the approach of a reasonable percentage of the
> destructive earthquakes which are occurring around the world. This report
> will explain how the program works.
>
> That program is presently already fully operational and in use. But
> for it to be effectively used by governments etc. around the world it will
> probably be necessary for some organization to "fine tune" the program code
> and the output data format and take charge of circulating the program and
> instructing government personnel regarding how to use it.
>
> Note: I don't have time to get into a lengthy discussion regarding this
> subject matter. If you post a response which asks questions which require
> lengthy answers, which are too difficult to answer, or if you ask too many
> questions I am not going to be able to respond to your note. Also, it might
> take me a few days to respond to any questions.
>
> This subject matter involves earthquakes, geophysics, celestial mechanics,
> and Perl language computer programming. That is why this report has been
> posted to a number of Newsgroups. If you wish to respond in just one of
> them I would recommend sci.geo.earthquakes.
>
> Present Theories:
>
> *** Earthquakes occur when fault zones collect enough strain energy as the
> result of tectonic plate movements etc. that their rock layers fracture.
>
> *** The actual times when many earthquakes occur and when certain types of
> fault zone process related electromagnetic energy field fluctuations (EM
> signals) are being generated are controlled by forces which are directly
> and/or indirectly related to the positions of the sun and the moon in the
> sky. The sun and moon gravities are controlling those forces. They add
> enough additional strain energy to the fault zone to trigger the earthquake.
>
> *** A given fault zone will tend to fracture when those forces bend,
> stretch, and compress its rock layers in certain directions. Years,
> decades, and even centuries may pass before the fault zone has stored enough
> energy for another earthquake to occur and it is once again bent etc. in
> such a manner that one is triggered. But this process is sufficiently
> repetitive and reliable that it can be used to forecast earthquakes.
>
> A computer program can be used to compare the times when those EM signals
> are generated with the times when earthquakes occurred in the past. And
> when matches are found between the signals and past earthquakes then that
> can serve as an indicator that a new earthquake is about to occur in the
> general area where the past one occurred.
>
> With the program I am presently using:
>
> About 500 EM signals are detected each year. They last from 0.25 to 20
> seconds. That short duration time can make it a little difficult to detect
> them. But it makes them ideal for use with this type of computer program.
>
> For each data point, about 3 months worth of signals, usually between 100
> and 200, are compared one by one with the roughly 25,000 earthquakes I have
> in my database. They occurred during the years 1990 through the present.
>
> To present a somewhat simplified picture, when signal # 1 is compared with
> the first earthquake in the database the earthquake is given a rating on a 0
> to 100 scale for how well the signal matched the earthquake. Then signal #
> 1 is compared with earthquake # 2.
>
> When all of the earthquakes have been checked the same steps are taken for
> signal # 2. And when those checks are finished the results of the first
> series of tests are added to the results of the second series of tests.
> This then continues for each of the signals.
>
> When all of the comparisons are done the result is a list of 25,000
> earthquakes which has a single probability rating for each earthquake which
> shows how it matched all of the signals combined.
>
> Some of those 150 or so signals will have preferentially matched one
> earthquake. And as a result it will have a higher rating. Some will have
> preferentially matched another etc.
>
> The list is adjusted so that the earthquake which was the best match for all
> of the signals (the highest results rating) is multiplied by some factor so
> that it has a final rating of 100. And all of the other earthquakes are
> then multiplied by that factor. They then have final ratings which range
> from 0 to 100.
>
> The next steps provide the information regarding when and where an
> earthquake is going to occur.
>
> A complete run like that takes about 30 minutes on a 700 Meg speed computer.
> And that series of tests is repeated about every 3 days.
>
> With each new test date the signals for the oldest 3 day period are removed
> from the test list. And signals detected during the latest 3 day period are
> added to it. So the list of signals gradually changes with time.
>
> If an earthquake at say 122W and 36N has a final rating of:
>
> 50 on day 1
> 60 on day 4
> 80 on day 7
> 93 on day 10
> 97 on day 13
> 99 on day 16
>
> That gradual increase in final ratings would then indicate that another
> earthquake could be about to occur near 122W and 36N.
>
> If and when it did occur, say on day 17, the final ratings for the 122W and
> 36N earthquake in the list would usually begin to go down as the warning
> signals which pointed to it were gradually removed from the test signal
> list.
>
> Because some 25,000 earthquakes which occurred around the world are given
> ratings with each series of tests, and because some of the signals during
> that 90 day test signal period will point to one earthquake and some will
> point to another, the final results list which is generated every 3 days
> shows were earthquakes around the world might be about to occur.
>
> An example for a single earthquake:
>
> On December 22, 2003 the following destructive earthquake occurred in
> California, U.S.A.
>
> 2003/12/22 19:15:56 35.71N 121.10W 7.6 6.5 CENTRAL CALIFORNIA
> (NEIS data)
>
> My data processing computer program was not fully operational until April of
> 2004. And so I could not use it to watch for that earthquake at the time
> that it occurred. However I recently used the program to test the signals
> which were detected back around then to see how well it might have done if
> it had existed last December. And it generated the following data.
>
> These were the final ratings for the following earthquake which is one of
> the ones in my 25,000 earthquake data table. It was one of the
> geographically closest ones to that December 22 earthquake.
>
> 1989/10/18 00:04:15 37.03N 121.88W 19.0 7.1 SAN FRANCISCO, CALIFORNIA
>
> The dates in this list are the end dates for each 3 month test signal
> period. The Pa: numbers represent final ratings for that San Francisco
> earthquake when it was compared with all of the 25,000 earthquakes in the
> database. The Pd: numbers represent final rating for that earthquake when
> it was compared with only those earthquakes in the database which produced
> fatalities.
>
> Test Date Pa: Pd:
>
> 03/10/30 71: 75
> 03/11/25 87: 89:
> 03/12/07 92: 94:
> 03/12/15 91: 96:
> 03/12/22 93: 97:
> 03/12/25 90: 95:
> 03/12/30 91: 94:
> 04/01/15 91: 91:
> 04/02/19 74: 81:
> 04/03/20 65: 69:
> 04/04/13 72: 77:
> 04/05/18 66: 67:
>
> Both the Pa: and Pd: final results numbers peaked beginning around December
> 7, continuing through December 30. And if that computer program had been
> operational back in December, and had government officials here in the U.S.
> and earthquake forecasters seen those numbers reach a peak for that San
> Francisco earthquake which occurred at 37N and 122W, then they might have
> been able to check that general area for other signs of an approaching
> earthquake such as large, fresh cracks in building foundations, radon gas
> releases, abrupt changes in ground water table levels etc. And perhaps it
> would have been possible to determine that the December 22 earthquake which
> occurred at 36N and 121W was getting ready to occur.
>
> PRESENT STATUS OF THIS FORECASTING PROGRAM
>
> This is not a futuristic computer program which will become available 10
> years from now. It is already fully operational. And several other people
> that I know of have it running on their computers at this time. Signal data
> are being collected each day. And for the past few months I have been
> storing final results data at one of my Web sites for examination and use by
> government officials etc. around the world. Anyone who can run a Perl
> language program on his or her computer can confirm the results himself or
> herself.
>
> The computer program and its enormous database files were also until
> recently available as free downloads from my Web site. However, that site
> allows just a limited number of visits each month (bandwidth allowance).
> And a few weeks ago it had become so popular that the monthly bandwidth was
> exceeded and the site temporarily shut down. When that happened I removed
> most of the large download files etc. from the site so that it would not
> crash immediately after it started running again. Additionally, I am in the
> process of producing a new final results Web page which has a format which
> makes it easier to interpret the data.
>
> I recently received the formal U.S. copyright ownership papers for one
> version of that Perl language data processing computer program. And, if I
> do not receive more requests than I can respond to I can send people e-mail
> copies of a version which is presently several months old but which produces
> the same type of data as the latest version. The final results data are
> simply formatted a little differently with the latest version. To run the
> program you need to first install a Perl computer language compiler on your
> computer. That takes just a few minutes. The following Web page contains
> instructions for how to obtain a free copy of a Perl compiler:
>
> http://www.freewebz.com/eq-forecasting/Perl.html
>
> The following file contains a copy of my earthquake forecasting Perl
> program. However that file does not contain the very large support files
> which are presently needed to run it.
>
> http://www.freewebz.com/eq-forecasting/311.zip
>
> That Perl program was designed to run with Windows XP. It will also run
> with Windows 98. To get it to run with other operating systems such as UNIX
> it is probably necessary to change some of its internal statements. I
> myself would not know what changes needed to be made. However, this is a
> text program. And such changes should be easy to make with any text editor
> if you are familiar with Perl language computer programming.
>
> The computer program works quite well with the EM signal data that I myself
> am collecting. It remains to be seen how well it will work with other types
> of data including EM signal data being collected by other people around the
> world.
>
> The next planned step is to create a new version of the final results data
> Web page and store it at my Web site for demonstration purposes. That might
> take a few days or perhaps as much as a few weeks. And at that time a
> program update note will probably be posted to the Newsgroups.
>
> Longer range, additional data need to be generated and evaluated. The Perl
> program should be rewritten using a more conventional programming format.
> It presently simply consists of a group of subroutines which have been
> linked together. Perhaps a different programming language should be used.
>
> The program contains scores of software settings which can be optimized for
> better performance. More sophisticated data processing routines should be
> added. And geophysicists should try to determine why the program actually
> works. It relies on an unusual geophysical theory model for how earthquakes
> are being triggered. And although the computer program produces good data
> indicating that the theory model has some value, the actual earthquake
> triggering mechanism is not yet understood.
>
> This is not a funded research effort. It is not being run in connection
> with any formal research group. And I myself have only limited amounts of
> time to devote to the effort. Progress is therefore not as rapid as I would
> like. But it is being slowly made.
>
> This first report was intended to simply let people know that the earthquake
> forecasting computer program which was described here now exists and to
> provide a preliminary explanation of how it works.
>
> COMMENT: THE PERL COMPUTER LANGUAGE
>
> Without being an expert on this subject I believe that the Perl language was
> probably created in part so that people who are not professional computer
> programmers could have a versatile language for use which was inexpensive
> (it is actually free), widely available, well supported, powerful, and not
> too difficult to learn. I would say that if that was the case then this
> application demonstrates that this goal was achieved. And the development
> of an effective, inexpensive, and easily used computer program for
> forecasting earthquakes and doing advanced research on them would certainly
> have to be considered an important application for any computer language.
Sir.
I have been through your website and while the data collection may be
superlative,the inferences drawn from multiple astronomical
correlations do not work in principle,some more obvious than
others.This is not to reject the correlations between astronomical
observations and earthquakes and indeed they may prove to be of
considerable benefit far removed from earthquake prediction.
Gravitationally,the position of the Sun and the moon makes no sense as
the driving force behind earthquakes are long term crustal movements
and insofar as you infer a direct bearing on the Sun's position and
earthquake location as a trigger for the event you cannot appeal to
gravitational causes.The Sun does not move,the Earth does and insofar
as axial rotation and orbital goes on regardless of whether we see
the Sun or not,the inference between the Sun's position and
earthquake location does not arise from gravitational consequence.
Orbitally,the earth is at a maximum velocity against axial rotation at
the perihelion and a minimum at the aphelion.Gravitationally,physics
works from a different perspective of constant orbital motion and
constant axial rotation so you are appealing to physicists who adhere
to axial and orbital motion like such -
http://astrosun2.astro.cornell.edu/academics/courses//astro201/sidereal.htm
You are no expected to know the difference between Kepler and Newton
but I do and this makes all the difference in approaching astronomical
influence on geological concerns.
This is incorrect -
"PHÆNOMENON IV.
That the fixed stars being at rest, the periodic times of the five
primary planets, and (whether of the sun about the earth, or) of the
earth about the sun, are in the sesquiplicate proportion of their mean
distances from the sun."
http://members.tripod.com/~gravitee/phaenomena.htm
This is correct -
"So strong was the support from the combination of my labour of
seventeen years on the observations of Brahe and the present study,
which conspired together, that at first I believed I was dreaming, and
assuming my conclusion among my basic premises. But it is absolutely
certain and exact that "the proportion between the periodic times of
any two planets is precisely the sesquialterate proportion of their
mean distances ..."
(Harmonice mundi Book 5, Chapter 3, trans. Aiton, Duncan and Field, p.
411). "
Kepler and Galileo who fought hard to get people to acknowledge the
heliocentric motion of planets took a sharp turn backwards at Newton
who introduced geocentric/heliocentric orbital equivalency.I will make
it simple for you,you may as well correlate earthquakes with fairies
or aliens than turn to celestial mechanics.
As for your open sourse appeal while copyrighting things,well,that is
not fooling anyone.
------------------------------
Date: Tue, 17 Aug 2004 11:47:01 +0100
From: Chris <no_thanks@bms.umist.ac.uk>
Subject: Re: has anybody write bioinformatics programme with perl
Message-Id: <4121e4c4@news.umist.ac.uk>
Anno Siegel wrote:
> hugo <hugoyg@163.com> wrote in comp.lang.perl.misc:
>> let talk about bioinformatics more.
>
> That happens on a mailing list. See
> http://www.perl.org/community.html and look for BioPerl.
>
> Anno
Although I agree this isn't the correct place to talk about
bioinformatics I disagree that BioPerl is the best place. The
BioPerl mailing list is to discuss BioPerl modules. BioPerl is
not a pre-requisite for doing bioinformatics with perl; I and
most bioinformaticians I know don't use BioPerl.
However, I don't know of a good (public) forum to discuss
bioinformatics as most of our discussions are done within our
department, which isn't unusual. Not a very 'open' view I
know...
Chris.
------------------------------
Date: Tue, 17 Aug 2004 12:01:25 +0100
From: Chris Cole <ithinkiam@gmail.com>
Subject: Re: has anybody write bioinformatics programme with perl
Message-Id: <pan.2004.08.17.11.01.23.255379@gmail.com>
On Mon, 16 Aug 2004 16:36:52 +0800, hugo wrote:
> let talk about bioinformatics more.
Hugo,
This is a very vague posting. If you have a specific bioinformatics
problem that you want to solve using perl, then ask it otherwise you're
not going to get many replies.
BTW in reply to your question; yes.
Chris.
------------------------------
Date: Tue, 17 Aug 2004 20:03:48 +1000
From: Iain Chalmers <bigiain@mightymedia.com.au>
Subject: Re: How to turn a number into graphics?
Message-Id: <bigiain-151AAF.20034817082004@individual.net>
In article <3wgUc.305$E7T1.33@news04.bloor.is.net.cable.rogers.com>,
"http://links.i6networks.com" <SaveWorldFromAids@alexa.com> wrote:
> Any free scripting turning numbers into a graph?
>
> Similar to an image/graphics counter. PHP or Perl
If you're planning on using this on a website, the easiest way is to
make 10 image files, one with each digit on it, and just have a simple
script to insert the required image tags into the html.
If you _really_ need to be dynamically generating images, the GD module
is a simple way to do simple things, and the various Image::Magik
modules will allow you to manipulate complex images in complex ways...
http://search.cpan.org/~lds/GD-2.16/GD.pm
http://search.cpan.org/~jcristy/PerlMagick-6.02/Magick.pm
There are about 250 other modules with "Image" in their name on CPAN
too, but I've never used any of them so can't comment on them...
(looking through that list though, I'm going to have to make some time
to play with a few of them... Image::EXIF, Image::Thumbnail,
Image::Timeline, Image::Worldmap... Where was I when these modules were
announced I weonder... Oooh, I just noticed ImagePwd and
GD::SecurityImage - one of them might be what the original poster
needs...)
big
--
"I say we take off and nuke the entire site from orbit.
That's the only way to be sure." - Ellen Ripley
------------------------------
Date: Tue, 17 Aug 2004 11:10:09 +0100
From: "Greg Brant" <Greg@zorlord.karoo.co.uk>
Subject: Re: How to turn a number into graphics?
Message-Id: <sZKdndAN3qPqRLzcSa8jmA@karoo.co.uk>
the GD library has the ability to create graphics on the fly.
have a look
$myNumber = 648;
// create new image
$myImage = imageCreate(100 ,100);
// load a font
$font = imageLoadFont('str file name'); // you will need to read into this
function cos i cant be bothered, its in the manual
imageString($myImage, $font, 10,10, $myNumber, 250);
the image functions page in the php manual shows how you can output an image
directly to the browser or
write a file to the webserver to use later
"http://links.i6networks.com" <SaveWorldFromAids@alexa.com> wrote in message
news:3wgUc.305$E7T1.33@news04.bloor.is.net.cable.rogers.com...
> Any free scripting turning numbers into a graph?
>
> Similar to an image/graphics counter. PHP or Perl
>
>
------------------------------
Date: Tue, 17 Aug 2004 12:05:35 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How to turn a number into graphics?
Message-Id: <2oe44cF9j11qU1@uni-berlin.de>
http://links.i6networks.com wrote:
> Any free scripting turning numbers into a graph?
>
> Similar to an image/graphics counter. PHP or Perl
http://www.google.com/
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 17 Aug 2004 08:59:39 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Materializing an indirect sort using only swap
Message-Id: <cfshdr$6nr$1@mamenchi.zrz.TU-Berlin.DE>
<ctcgag@hotmail.com> wrote in comp.lang.perl.misc:
> Good day, all.
>
> I have a object which has sub-objects. The object only provides
> one way to re-order sub-objects: a somewhat expensive swap operation.
>
> I have code that does an indirect sort of the sub-objects:
>
> my @x;
> foreach my $i (1..$o->nofSub()) {
> push @x, compute_value($o,$i);
> };
> my @idx = "dummy", sort {$x[$a]<=>$x[$b]} 0..$#x;
>
> Now, I merely have to use @idx as a translation table so that I can access
> sub-objects as if they were sorted. Works great for the most part, but
> I've reached a point where that isn't good enough and I need to materialize
> the sort into the object itself. So I'm trying to use the transformation
> implied in @idx to apply a proper series of $o->swap($foo,$bar) operations
> to put the sub-objects in order.
>
> All the easy solutions I've come up with are about equivalent to selection
> sort (O(N) swaps, O(N**2) comparisons). In this case, that will work
> (because the nofSub never gets more than a few hundred), but its inelegance
> and poor scaling offend me.
>
> One solution is to add hooks into the object code to allow more efficient
> re-organization, but I know that there must be a better, elegant way to do
> it with just @idx and swap(). Any clues?
@idx is a permutation of the numbers 0 .. n. For an optimal sequence of
swap operations, resolve the permutation into disjunct cycles.
Each cycle describes a sequence of swap operations which together
realize the permutation.
I'll bet that the algorithm Japhy has announced will amount to
exactly this.
Anno
------------------------------
Date: 17 Aug 2004 10:11:23 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Materializing an indirect sort using only swap
Message-Id: <cfslkb$9r1$1@mamenchi.zrz.TU-Berlin.DE>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote in comp.lang.perl.misc:
> <ctcgag@hotmail.com> wrote in comp.lang.perl.misc:
> > Good day, all.
> >
> > I have a object which has sub-objects. The object only provides
> > one way to re-order sub-objects: a somewhat expensive swap operation.
> >
> > I have code that does an indirect sort of the sub-objects:
> >
> > my @x;
> > foreach my $i (1..$o->nofSub()) {
> > push @x, compute_value($o,$i);
> > };
> > my @idx = "dummy", sort {$x[$a]<=>$x[$b]} 0..$#x;
> >
> > Now, I merely have to use @idx as a translation table so that I can access
> > sub-objects as if they were sorted. Works great for the most part, but
> > I've reached a point where that isn't good enough and I need to materialize
> > the sort into the object itself. So I'm trying to use the transformation
> > implied in @idx to apply a proper series of $o->swap($foo,$bar) operations
> > to put the sub-objects in order.
> >
> > All the easy solutions I've come up with are about equivalent to selection
> > sort (O(N) swaps, O(N**2) comparisons). In this case, that will work
> > (because the nofSub never gets more than a few hundred), but its inelegance
> > and poor scaling offend me.
> >
> > One solution is to add hooks into the object code to allow more efficient
> > re-organization, but I know that there must be a better, elegant way to do
> > it with just @idx and swap(). Any clues?
>
> @idx is a permutation of the numbers 0 .. n. For an optimal sequence of
> swap operations, resolve the permutation into disjunct cycles.
> Each cycle describes a sequence of swap operations which together
> realize the permutation.
>
> I'll bet that the algorithm Japhy has announced will amount to
> exactly this.
Okay, here is my approach:
my @perm = qw( 3 5 1 2 0 4 ); # this is a single cycle
# my @perm = qw( 1 2 0 4 5 3 ); # two cycles
print "perm: @perm\n\n";
my @cycles;
while ( 1 ) {
pop @perm while @perm and $perm[ -1] == $#perm; # remove fix points
last unless @perm;
my @cyc = $#perm;
while ( ( my $el = $perm[ $cyc[ -1]]) != $cyc[ 0] ) {
push @cyc, $el;
}
$perm[ $_] = $_ for @cyc; # make these fix points
push @cycles, \ @cyc;
}
print "cycle: @$_\n" for @cycles;
This is to see if it worked:
my @array = 0 .. 5;
for my $cyc ( @cycles ) {
for ( 0 .. $#$cyc - 1 ) {
swap( \ @array, $cyc->[ $_], $cyc->[ $_ + 1]);
}
}
print "reconst: @array\n";
exit;
sub swap {
my ( $a, $i, $k) = @_;
@$a[ $i, $k] = @$a[ $k, $i]
}
------------------------------
Date: 17 Aug 2004 06:00:21 -0700
From: jkeen_via_google@yahoo.com (Jim Keenan)
Subject: Re: Module to filter HTML
Message-Id: <196cb7af.0408170500.4468b933@posting.google.com>
Vito Corleone <corleone@godfather.com> wrote in message news:<20040817114836.741d9e28.corleone@godfather.com>...
> Hi,
> I am looking for module to filter HTML input from user. It should allow
> <b> <i> <img> and some other tags, and remove the evil tags. I found
> HTML::Sanitizer, but the last update is August 2003. Is there any other
> alternative? Or is it ok to use HTML::Sanitizer? Thank you very much.
>
> --Vito
The mere fact that a module has not had a version update in twelve
months does not, in and of itself, preclude its use. Perhaps the
module met the author's goals at that point and, lacking feedback from
other users, there was no compelling reason for him/her to revise it
further.
The author of HTML::Sanitizer does caution the user about the "low
version number," but the documentation does suggest that he put a lot
of thought into it.
So my suggestions: (1) Try the module out in a non-production
environment with typical user input. (2) If it doesn't do what you
want, try some of the other, better known modules to which the author
provides links in the "SEE ALSO" section.
jimk
------------------------------
Date: 17 Aug 2004 04:05:31 -0700
From: mrazek@compik.fd.cvut.cz (Martin Mrazek)
Subject: Operator for presence of value in list?
Message-Id: <dcd39e84.0408170305.274cf68c@posting.google.com>
Hi,
I'm new to Perl. Is there something like in operator?
$a in @list; returns 1 if $a is among values in @list, 0 if not.
I'm just lazy to write foreach $elem (@list) { if ($a eq $elem) {
return 1;} } return 0;
Martin
------------------------------
Date: Tue, 17 Aug 2004 13:06:53 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Operator for presence of value in list?
Message-Id: <2oe7nfF9htngU1@uni-berlin.de>
Martin Mrazek wrote:
> I'm new to Perl.
Then you should start learning how to make use of the documentation.
> Is there something like in operator?
>
> $a in @list; returns 1 if $a is among values in @list, 0 if not.
You just asked a Frequently Asked Question.
perldoc -q contained
"How can I tell whether a certain element is contained in a
list or array?"
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 17 Aug 2004 13:19:07 +0200
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: Operator for presence of value in list?
Message-Id: <Xns954887F3FE839elhber1lidotechnet@62.89.127.66>
mrazek@compik.fd.cvut.cz (Martin Mrazek) wrote:
> Hi,
> I'm new to Perl. Is there something like in operator?
>
> $a in @list; returns 1 if $a is among values in @list, 0 if not.
>
> I'm just lazy to write foreach $elem (@list) { if ($a eq $elem) {
> return 1;} } return 0;
perldoc -f grep
--
Cheers,
Bernard
------------------------------
Date: Tue, 17 Aug 2004 13:17:14 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Operator for presence of value in list?
Message-Id: <2oe8atF9rmeqU1@uni-berlin.de>
Bernard El-Hagin wrote:
> Martin Mrazek wrote:
>> I'm new to Perl. Is there something like in operator?
>>
>> $a in @list; returns 1 if $a is among values in @list, 0 if not.
>
> perldoc -f grep
Quote from the applicable Perl FAQ ("perldoc -q contained"):
"Please do not use
($is_there) = grep $_ eq $whatever, @array;
or worse yet
($is_there) = grep /$whatever/, @array;
These are slow (checks every element even if the first matches),
inefficient (same reason), and potentially buggy (what if there are
regex characters in $whatever?)."
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 17 Aug 2004 13:35:26 +0200
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: Operator for presence of value in list?
Message-Id: <Xns95488AB83E3A8elhber1lidotechnet@62.89.127.66>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> Bernard El-Hagin wrote:
>> Martin Mrazek wrote:
>>> I'm new to Perl. Is there something like in operator?
>>>
>>> $a in @list; returns 1 if $a is among values in @list, 0 if not.
>>
>> perldoc -f grep
>
> Quote from the applicable Perl FAQ ("perldoc -q contained"):
>
> "Please do not use
>
> ($is_there) = grep $_ eq $whatever, @array;
>
> or worse yet
>
> ($is_there) = grep /$whatever/, @array;
>
> These are slow (checks every element even if the first matches),
> inefficient (same reason), and potentially buggy (what if there are
> regex characters in $whatever?)."
Good, you're paying attention. ;-)
--
Cheers,
Bernard
------------------------------
Date: Tue, 17 Aug 2004 13:49:50 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Operator for presence of value in list?
Message-Id: <2oea84F9p19eU1@uni-berlin.de>
Bernard El-Hagin wrote:
> Gunnar Hjalmarsson wrote:
>> Bernard El-Hagin wrote:
>>>
>>> perldoc -f grep
>>
>> Quote from the applicable Perl FAQ ("perldoc -q contained"):
>>
>> "Please do not use
>>
>> ($is_there) = grep $_ eq $whatever, @array;
>>
>> or worse yet
>>
>> ($is_there) = grep /$whatever/, @array;
>>
>> These are slow (checks every element even if the first matches),
>> inefficient (same reason), and potentially buggy (what if there
>> are regex characters in $whatever?)."
>
> Good, you're paying attention. ;-)
Yeah, I like being a pain in the a**. :)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 17 Aug 2004 12:12:42 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Parsing a text file into an array
Message-Id: <cfssnq$ers$2@mamenchi.zrz.TU-Berlin.DE>
Scott <sroth1979@hotmail.com> wrote in comp.lang.perl.misc:
> I having a bit of trouble trying to parse...
>
> 789798798 test,test 12/5/3005
>
> with tabs between each column. Does any one have some suggestions?
What *is* a column? Ther are no tabs in the line above (probably lost
in news propagation). So are there three, four, or six columns?
Anno
------------------------------
Date: 17 Aug 2004 11:37:59 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: Placeholder in an sql query
Message-Id: <Xns9548444ECF17Debohlmanomsdevcom@130.133.1.4>
dn_perl@hotmail.com (dn_perl@hotmail.com) wrote in
news:97314b5b.0408162143.2cd50109@posting.google.com:
> If I use placeholder for 'loc' field, I get the expected result.
> my $dstmt = $dbh->prepare("select count(*) from inventory
> where part = '$check_part' and loc = ? ");
> $dstmt->execute($check_location) or die "sql call failed";
>
>
> But if I use placeholder for 'part' field, things go wrong.
> my $dstmt = $dbh->prepare("select count(*) from inventory
> where part = ? and loc = '$check_location' ");
> $dstmt->execute($check_part) or die "sql call failed";
> my $num_entries = $dstmt->fetchrow() ;
> I get $num_entries = 0 instead of 1 .
You say it's the "part" field giving you the problem while the "loc" field
works OK, but another possible interpretation of the problem is that the
first (or only) field in a WHERE clause gives you a problem while the
second one works OK. Try reversing the order of the two and see what
happens.
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 6874
***************************************