[17975] in Perl-Users-Digest
Perl-Users Digest, Issue: 135 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 24 19:09:33 2001
Date: Wed, 24 Jan 2001 15:10:26 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <980377826-v10-i135@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 24 Jan 2001 Volume: 10 Number: 135
Today's topics:
messageboard on NT - IIS <jpcrisci@usgs.gov>
Re: messageboard on NT - IIS <godzilla@stomp.stomp.tokyo>
Re: messageboard on NT - IIS <amonotod@netscape.net>
Nested Selects amerar6996@my-deja.com
Re: Nested Selects nobull@mail.com
Re: Newbie question : Read configuration file. <claytons@nortelnetworks.com>
Re: Newbie question : Read configuration file. (Eric Bohlman)
Re: partition a large file into a number of small ones (Rich Lafferty)
Re: passing parameters to perl cronjob? <news@sinik.de>
Perl and Java <ducateg@info.bt.co.uk>
Re: Perl and Java <bas@integrators.demon.nl>
Re: Perl is bad at (very) simple math! <camerond@mail.uca.edu>
Re: Perl is bad at (very) simple math! jw_c@my-deja.com
Re: Perl is bad at (very) simple math! jw_c@my-deja.com
Re: Perl is bad at (very) simple math! <mischief@velma.motion.net>
Problem Connecting to Database <robinc@LMGroup.com>
Re: Problem installing DBD-Oracle allym@my-deja.com
Re: Random Numbers with a Twist (Abigail)
RegEx: Removing spaces between tags bobbybobbob@my-deja.com
Re: RegEx: Removing spaces between tags (Anno Siegel)
Re: RegEx: Removing spaces between tags bobbybobbob@my-deja.com
Re: RegEx: Removing spaces between tags <tore@extend.no>
Re: RegEx: Removing spaces between tags (Tad McClellan)
Re: s/// inconsistency (Ilya Zakharevich)
Re: spawning a process that is a perl program <amonotod@netscape.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 24 Jan 2001 17:10:36 GMT
From: John Crisci <jpcrisci@usgs.gov>
Subject: messageboard on NT - IIS
Message-Id: <3A6F0C8C.995AFD2C@usgs.gov>
Hi
I downloaded wwwboard.pl (message board from Matt Wrights's home page)
and have attempted to install it on NT4.0 IIS 4.0. After I get it
working I wanted to change to IIS 5.0 on Win 2000. One of the problems I
am having is : when I submit the web data through a form to the perl
program, I can't make it pop into the debugger so I can trace what is
going on. It is not writing back to the main html like it's supposed to
and I have set every permission I can think of on IIS.
I have it partially working at this point.
Question: Can someone tell me how to send the data with the web form and
open up the debugger?
TIA
John Crisci
------------------------------
Date: Wed, 24 Jan 2001 10:56:25 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: messageboard on NT - IIS
Message-Id: <3A6F2559.D6924E9F@stomp.stomp.tokyo>
John Crisci wrote:
(various snippage)
> I downloaded wwwboard.pl (message board from Matt Wrights's home page)
> One of the problems I am having is : when I submit the web data through
> a form to the perl program, I can't make it pop into the debugger so
> I can trace what is going on.
> Can someone tell me how to send the data with the web form and
> open up the debugger?
Rather than struggle with dumping data into a debugger,
make Matt's script itself, a debugger. This is very easy
to do but requires some work on your part. Nonetheless,
it is an infallible system; I use this method frequently.
Doing this only requires good planning and some typing.
However, before making his script a debugger, there are
three very common failures for this type of script.
Failure to use a full internal path for file actions.
Permissions are not correctly set for a write.
Post actions are not allowed for a critical directory.
An internal path is not an URL but rather a machine internal
path to a directory tree and subsequent file. Example:
/var/ftp/home/callgirl/board/board.log
Your paths to your read and write files should be similar.
Permissions are challenging. Some server configurations
only require write permissions for you, this is, your
script. Other configurations require write permissions
for everyone; www write permissions. Check on this.
A Post Action error usually results in a very clear
error message, "Post Method Not Allowed." Based on
your comments, it appears post actions are allowed
for your directory tree. Double check this, however.
Isolate sections of this script for debugging by adding
print commands, this is, prints to your screen, followed
by an exit command. As you debug, more prints are added
and this exit command is moved farther into the script.
Here are some simple incomplete examples of this method.
Find this, top of Matt's script:
# Define Variables
$basedir = "/path/to/wwwboard";
$baseurl = "http://your.host.xxx/wwwboard";
$cgi_url = "http://your.host.xxx/cgi-bin/wwwboard.pl";
Add print commands followed by an exit; command:
$basedir = "/path/to/wwwboard";
print "Base directory is: $basedir\n";
$baseurl = "http://your.host.xxx/wwwboard";
print "Base URL is: $baseurl\n";
$cgi_url = "http://your.host.xxx/cgi-bin/wwwboard.pl";
print "CGI URL is: $cgi_url\n";
(continue through your variables with prints)
exit;
This confirms your script is executing and confirms
you have data flow back to your screen. You should
see a print of file location variables, then an exit.
If all is correct, leave your prints and remove
your closing exit command.
Find this in Matt's script, end of his read and parse:
$FORM{$name} = $value;
Add this within his foreach loop:
print "Form Name is: $name Value is: $value\n";
$FORM{$name} = $value;
}
exit;
A print command has been added at the tailend of
his read and parse foreach loop, followed by a
new exit command. You should see both your file
paths, as before, and your form action data input
printed, then an exit. This confirms your form
action is passing along data to your script.
I have moved way down into his script, skipping a lot
of sections for brevity. Add debugging to previous
sections as needed. Find this:
sub new_file {
open(NEWFILE,">$basedir/$mesgdir/$num\.$ext") || die $!;
print NEWFILE "<html>\n";
Make these changes:
sub new_file {
print "Opening $basedir/$mesgdir/$num\.$ext\n";
open(NEWFILE,">$basedir/$mesgdir/$num\.$ext") || die $!;
print "Print to file is active\n";
print NEWFILE "<html>\n";
(remaining file prints and file closure)
exit;
This style of debugging confirms your script has
reached a file open section. Having a print just
before a file open, makes this confirmation. This
"Print to file is active" confirms your script
made it past the file open ok. After exit, you
can manually open this file and confirm a print
to file was successful.
At this stage, you would see all previous prints
on your monitor and this new file open print,
followed by an exit.
I have moved farther down in his script. Find this:
sub main_page {
open(MAIN,"$basedir/$mesgfile") || die $!;
@main = <MAIN>;
close(MAIN);
Change to:
sub main_page {
print "Opening $basedir/$mesgfile\n";
open(MAIN,"$basedir/$mesgfile") || die $!;
@main = <MAIN>;
close(MAIN);
if (!(@main))
{ print "Main Array Was Not Created.\n"; exit; }
This previous example shows how you can confirm
reaching a file open section and confirm a read
and creation of an array for data manipulation.
If there is a failure with your array, a message
is printed and an exit.
These examples I give are scattered examples but
show how you can slowly work your way through a
script adding print commands and a final exit
command to make a script a debugger. Careful
planning is crucial to this method. It does
work well but requires work on your part.
Consider using your script itself as a debugger
rather than relying on a data dump to a debugger.
This is a very direct method of dealing with
script problems.
Best of luck with your script.
Godzilla!
------------------------------
Date: Wed, 24 Jan 2001 21:01:30 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: messageboard on NT - IIS
Message-Id: <94nfr2$qua$1@nnrp1.deja.com>
In article <3A6F2559.D6924E9F@stomp.stomp.tokyo>,
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
> John Crisci wrote:
>
> (various snippage)
>
> > I downloaded wwwboard.pl (message board from Matt Wrights's home
> > page)
<snip>
> However, before making his script a debugger, there are
> three very common failures for this type of script.
>
> Failure to use a full internal path for file actions.
> Permissions are not correctly set for a write.
> Post actions are not allowed for a critical directory.
>
<snip>
As usual, you missed the biggest freaking point of all... Unless Matt
has rewritten his entire script, it's a major security problem. Unless
the OP likes the idea of having his website/message board
defaced/deleted by anybody who feels like doing it, he should get a
different script, or maybe even a commercial product.
Once again omitting the important advice:
> Godzilla!
>
You stupid troll!
amonotod
--
`\|||/ amonotod@
(@@) netscape.net
ooO_(_)_Ooo________________________________
_____|_____|_____|_____|_____|_____|_____|_____|
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 24 Jan 2001 17:14:00 GMT
From: amerar6996@my-deja.com
Subject: Nested Selects
Message-Id: <94n2gc$dhe$1@nnrp1.deja.com>
Hello,
I'm a bit new to DBI. I am trying to write a
while loop to do a nested select. Below is the
code I wrote, which is NOT working at all. Can
anyone help out or point me to where I can find
some examples of this?
Please CC a copy to my e-mail.....thanks.
$select = "SELECT caps_code,tot_rev, tot_eft
FROM revanal_summary
WHERE summary_date_time =
TO_DATE(?,'MMDDYYYY')";
$mon_db = $dbh->prepare($select);
$mon_db->execute( $mon_st );
($caps_code,$monthly_neft,$monthly_eft)=$mon_db-
>fetchrow();
while ( $caps_code =
$mon_db->fetchrow_array( ) ) {
$select = "SELECT SUM(NVL(amt_cash,0)) +
SUM(NVL(amt_check,0)) +
SUM(NVL(advice_of_credit,0)) +
SUM(NVL(letter_of_credit,0)) +
SUM(NVL(food_stamps,0)) +
SUM(NVL(credit_others,0)),
SUM(NVL(electronic_fund_transfer,0))
FROM payment_history_view
WHERE trandatetime >=
TO_DATE(?,'MMDDYYYY') AND
trandatetime <=
TO_DATE(?,'MMDDYYYY') AND
caps_code = ?";
$ph_db = $dbh->prepare($select);
$ph_db->execute($mon_st,$mon_end, $caps_code);
($payhis_neft,$payhis_eft)=$ph_db->fetchrow();
.
.
.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 24 Jan 2001 18:23:37 +0000
From: nobull@mail.com
Subject: Re: Nested Selects
Message-Id: <u966j4izbq.fsf@wcl-l.bham.ac.uk>
amerar6996@my-deja.com writes:
> I'm a bit new to DBI. I am trying to write a
> while loop to do a nested select. Below is the
> code I wrote, which is NOT working at all.
No! Do not say that. Give us a resonable idea of how it is failing.
If you can't do that then you have not tried hard enough.
Do you have your DBI object configured to throw exceptions? If not
then you must explicitly check for errors when you call DBI methods.
Note: some DBI database drivers cannot sopport multiple concurrent operations.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 24 Jan 2001 11:31:31 -0500
From: Clayton Scott <claytons@nortelnetworks.com>
Subject: Re: Newbie question : Read configuration file.
Message-Id: <3A6F0363.D0313C6A@nortelnetworks.com>
Andy Geraerts wrote:
>
> >Damian has suggested changing the $$1 to $config{$1}, >may I suggest
>
> The first line is only applicable if you use 'hashes'?
Here's why you should use hashes
or "Why it's stupid to `use a variable as a variable name'":
http://perl.plover.com/varvarname.html
by Mark-Jason Dominus
Clayton
------------------------------
Date: 24 Jan 2001 21:10:12 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Newbie question : Read configuration file.
Message-Id: <94ngbk$kcl$1@bob.news.rcn.net>
Andy Geraerts <angeraer@hotmail.com> wrote:
>>Damian has suggested changing the $$1 to $config{$1}, >may I suggest
> changing the second re to
>>next unless /^(\w+)\s*=\s*(.*)/;
> The first line is only applicable if you use 'hashes'?
> What does the second line do?
The suggested change to the second line lets it work properly if there are
spaces or tabs surrounding the equal sign, which there might well be if
humans edit the config file.
------------------------------
Date: 24 Jan 2001 16:07:05 GMT
From: rich@bofh.concordia.ca (Rich Lafferty)
Subject: Re: partition a large file into a number of small ones
Message-Id: <slrn96tve7.69i.rich@bofh.concordia.ca>
In comp.lang.perl.misc,
mcgowan@alum.mit.edu <mcgowan@alum.mit.edu> wrote:
> rich@bofh.concordia.ca (Rich Lafferty) wrote:
> >
> > In comp.lang.perl.misc,
> > Derek M. Flynn <dmf@cs.uchicago.edu> wrote:
> > > Y. Zhang wrote:
> > > > Hi,
> > > > I have a text file which is huge one (~270mb) with million lines. I
> > > > want to divide this file into small ones (50 mb or 4000 lines each). I
> > > > am use a unix osf system.
> > > >
> > > > Any advice is appreciated.
> > >
> > > man split
> >
> > You can do it in Perl!
>
> at the great risk of getting tangential, why?
History (HELLO comp.lang.shell!) and mountain-climbing. Did you see the
list at <http://language.perl.com/ppt/what.html>? I mean, who
*wouldn't* want to hunt the Wumpus in Perl?
-Rich
--
Rich Lafferty ----------------------------------------
Nocturnal Aviation Division, IITS Computing Services
Concordia University, Montreal, QC
rich@bofh.concordia.ca -------------------------------
------------------------------
Date: Wed, 24 Jan 2001 17:55:37 +0100
From: "Carsten Nielsen" <news@sinik.de>
Subject: Re: passing parameters to perl cronjob?
Message-Id: <94n1eb$4oa$05$1@news.t-online.com>
> A CGI program executed from a crontab ???
Sorry Rafael,
I'am an ...
Coming from webprogramming, http://only_think_dot_net
>(via @ARGV, see the perlvar manual page) instead of CGI.pm.
works fine,
thanks and never mind...
Carsten
------------------------------
Date: Wed, 24 Jan 2001 18:36:40 -0000
From: "Géry" <ducateg@info.bt.co.uk>
Subject: Perl and Java
Message-Id: <94n7gq$qqu$1@pheidippides.axion.bt.co.uk>
I want to stream a perl hash to populate a hash table in a java piece of
code. I do
not want to use an intermediate file...
Can I simply pass the object reference and expect that the perl hash
structure will turn into a valid java hash table, or do I need to populate
the java hash table passing some string values from a perl sub function? I
guess I wand to pipe the data, but then how do I go about doing it?
So if I end a perl script with:
return %myhash;
how do I get it back into a java piece of code...
Of course, I am simply looking for guidelines, not complete solutions...
Many thanks in advance
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Géry
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
------------------------------
Date: Wed, 24 Jan 2001 23:15:51 +0100
From: "Bas A. Schulte" <bas@integrators.demon.nl>
Subject: Re: Perl and Java
Message-Id: <bas-A5F19F.23155124012001@news.demon.nl>
Hi,
> Can I simply pass the object reference and expect that the perl hash
> structure will turn into a valid java hash table, or do I need to populate
> the java hash table passing some string values from a perl sub function? I
> guess I wand to pipe the data, but then how do I go about doing it?
I would look into something like SOAP or XML-RPC. There's software for
both of them already out there for both perl and Java. It allows you to
move arbitrary pieces of structured data from A to B. A is perl, B is
Java ;)
Wouldn't device a marshalling and transmission technique myself if I
were you.
Regards,
Bas.
------------------------------
Date: Wed, 24 Jan 2001 10:30:28 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Perl is bad at (very) simple math!
Message-Id: <3A6F0324.967850F7@mail.uca.edu>
Michael Stopp wrote:
>
> Can anybody explain why a perl script as simple as this can fail?
>
> $a = 5.1;
> $b = 5;
> print $a-$b, "\n";
>
> This produces:
>
> 0.0999999999999996
>
> I tested this on a Linux box (Perl 5.005_02, Kernel 2.0.35) and
> a Windows machine (Active Perl 5.005_03, Win98): same result.
> Can this be true?!? What can one do about this?
Actually the FAQ that everyone is pointing to is wrong. Perl gives
EXACTLY the CORRECT answer! I just performed the calculation using
pencil and paper (and the advanced math I had in college
29.9999999999994 years ago) and got the same answer, to the last decimal
place. Of course, math could have changed in the last 29.9999999999994
years, I guess.
Cameron
--
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu
------------------------------
Date: Wed, 24 Jan 2001 18:04:46 GMT
From: jw_c@my-deja.com
Subject: Re: Perl is bad at (very) simple math!
Message-Id: <94n5fn$gem$1@nnrp1.deja.com>
In article <slrn96thdg.124.abigail@tsathoggua.rlyeh.net>,
abigail@foad.org wrote:
> What can be done about it is easy: get rid of the idea that doing
> floating point arithmetic using binary computers that consist of
> a finite amount of atoms is actually feasible.
Sadly, Purchasing keeps losing my requisition for a computer
with an infinite number of atoms.....
:)
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 24 Jan 2001 18:09:07 GMT
From: jw_c@my-deja.com
Subject: Re: Perl is bad at (very) simple math!
Message-Id: <94n5nq$gq8$1@nnrp1.deja.com>
In article <3A6EB808.D80DD247@unibas.ubaclu.ch>,
Michael Stopp <stopp@eye.ch> wrote:
> Can anybody explain why a perl script as simple as this can fail?
> $a = 5.1;
> $b = 5;
> print $a-$b, "\n";
> This produces:
> 0.0999999999999996
Horrors!
> I tested this on a Linux box (Perl 5.005_02, Kernel 2.0.35) and
> a Windows machine (Active Perl 5.005_03, Win98): same result.
> Can this be true?!? What can one do about this?
One can:
1. Read the Perl FAQ
2. Do a Deja/Google/AltaVista search on "floating point error"
3. Read the paper "What Every Computer Scientist Should Know About
Floating Point Math" that's hidden somewhere on most Suns
(or used to be).
4. Write the program you show in C, C++, Java, FORTRAN, etc.
4a. Run said program.
4b. Ponder the results.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 24 Jan 2001 21:26:06 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Perl is bad at (very) simple math!
Message-Id: <t6ui3ecdn4pn39@corp.supernews.com>
Michael Stopp <stopp@eye.ch> wrote:
> Can anybody explain why a perl script as simple as this can fail?
> $a = 5.1;
> $b = 5;
> print $a-$b, "\n";
> This produces:
> 0.0999999999999996
I wouldn't call that failing. Figure out for yourself how to
represent 0.1 in binary.
There is such a thing as arbitrary precision mathematics, but
computer hardware tend snot to support it. Perl uses the math
capabilities present in the host platform.
There are mathematics libraries for Perl. I'm not sure if there's
an arbitrary precision math module or not. Feel free to develop
and release one. If this sounds like too much work, take a look
at CPAN for math modules that are more exacting than the default
of using the hardware.
> I tested this on a Linux box (Perl 5.005_02, Kernel 2.0.35) and
> a Windows machine (Active Perl 5.005_03, Win98): same result.
> Can this be true?!? What can one do about this?
This is true. One can lower one's expectations from perfection to
reality, one can choose a language which supports more precise
floating point operation, one can extend the existing language
to use more precision, or one can make use of existing language
extensions which provide more precision.
Chris
--
Christopher E. Stith
Programming is a tool. A tool is neither good nor evil. It is
the user who determines how it is used and to what ends.
------------------------------
Date: Wed, 24 Jan 2001 21:42:35 GMT
From: "Robin Corcoran" <robinc@LMGroup.com>
Subject: Problem Connecting to Database
Message-Id: <f%Hb6.1013$UU2.34088245@nnrp1.tor.metronet.ca>
Hello,
I have an XML file which I am extracting some information from, no problem
there. I would then like to put this information into an Access database.
I've never done anything with databases, so I tried using some DBI
information from this URL.
http://www.perl.com/pub/1999/10/DBI.html
I have cut and pasted the code from there, changing only Oracle to ODBC
(xml.mdb is the name of my database).
#!usr/perl/bin -w
use DBI;
use strict;
my $dbh = DBI->connect('DBI:ODBC:xml')
or die "Couldn't connect to database: " . DBI->errstr;
#Commented out until I can at least connect to the database
#my $sth = $dbh->prepare('SELECT * FROM people WHERE lastname = ?')
# or die "Couldn't prepare statement: " . $dbh->errstr;
print "Hello\n";
$dbh->disconnect;
I searched the FAQ's for DBI, and everything looks right, but I am getting
the following errors:
DBI->connect(xml) failed: [Microsoft][ODBC Driver Manager] Data source name
not found and no default driver specified (SQL-IM002)(DBD:
db_login/SQLConnect err=-1) at C:\For Joe\cpc_xml\database.pl line 5
Couldn't connect to database: [Microsoft][ODBC Driver Manager] Data source
name not found and no default driver specified (SQL-IM002)(DBD:
db_login/SQLConnect err=-1) at C:\For Joe\cpc_xml\database.pl line 5.
Here's what I am using : Perl 5.6.0, win98, Access 97.
Any help would be appreciated,
Robin
------------------------------
Date: Wed, 24 Jan 2001 16:12:48 GMT
From: allym@my-deja.com
Subject: Re: Problem installing DBD-Oracle
Message-Id: <94mutk$9s0$1@nnrp1.deja.com>
In article <943b25$spp$1@perki.connect.com.au>,
"Steve Baldwin" <steven.baldwin@hancorp.com.au> wrote:
> Hi,
>
> I apologize for posting to this group, but I've tried subscribing to
the
> dbi-users mailing list at http://www.fugue.com/dbi and it doesn't seem
to be
> working.
...
> gcc. I have attached 'script' output of an attempted build session
for
> DBD-Oracle.
>
> I have got Pro*C installed (not sure if it is needed or not), and I
can
> quite happily compile and execute Pro*C programs, so I'm pretty sure
that
> side of things is OK.
>
> I have included output of 'perl -V', in case I have done anything
stupid
> when I built perl - although I have installed DBI-1.14 (apparently)
> successfully.
>
> I would really appreciate anyone's help here. I need to get this up
and
> running 'yesterday'.
>
> Thanks,
>
> Steve Baldwin
>
> P.S.
> I've tried various options (-8, LINKTYPE=static), but to no avail.
>
The README.help file says
------------------------------------------------------------------------
-------
For platforms which require static linking.
You'll need to build DBD::Oracle statically linked and then link it
into a perl binary:
perl Makefile.PL LINKTYPE=static
make
make perl (makes a perl binary in current
directory)
make test FULLPERL=./perl (run tests using the new perl binary)
make install
You will probably need to have already built and installed a static
version of the DBI in order that it be automatically included when
you do the 'make perl' above.
Remember that you must use this new perl binary to access Oracle.
There's more advice about building for HP/UX, but that's what I'm about
to do (after looking for other solutions on Deja and coming across your
post
Regards,
Ally
PS: Sorry if someone else has already replied. Dejas archive is a
little hit-and-miss.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 24 Jan 2001 22:02:28 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Random Numbers with a Twist
Message-Id: <slrn96uk7k.a8v.abigail@tsathoggua.rlyeh.net>
Gordon.Haverland@agric.gov.ab.ca (Gordon.Haverland@agric.gov.ab.ca) wrote
on MMDCCIII September MCMXCIII in <URL:news:3a6eea7c.501397501@news.gov.ab.ca>:
~~ On 23 Jan 2001 18:23:34 GMT, abigail@foad.org (Abigail) wrote:
~~
~~ >Gordon.Haverland@agric.gov.ab.ca (Gordon.Haverland@agric.gov.ab.ca) wrote
~~ >on MMDCCII September MCMXCIII in <URL:news:3a6d8d78.412036016@news.gov.ab.ca>:
~~ >:)
~~ >:) >On 20 Jan 2001 00:42:40 GMT, abigail@foad.org (Abigail) wrote:
~~ >:) >
~~ >:) >>The hard part is deciding when to stop, that is, when is the set
~~ >:) >>random enough?
~~ >:)
~~ >:) You are heading down a slippery path on this one! It is entirely
~~ >:) possible to "draw" random coordinates from a universe of points and
~~ >:) end up with something that is highly ordered/symmetric. It may be
~~ >:) unlikely, but it is possible. If you reject a given outcome for being
~~ >:) "unrandom" according to your personal feelings, you bias your results.
~~ >
~~ >
~~ >Oh, I wasn't suggesting you couldn't stop because the result still
~~ >looked to ordered. You would have to decide in advance when to stop
~~ >- and that is the hard problem.
~~
~~ If I remember earlier parts of this thread correctly, your problem has
~~ a built in rejection component. You generate trial points and
~~ possibly reject a point if it fits certain criteria. The easiest
~~ stopping rule is going to be N successive rejections. As soon as a
~~ trial point is accepted, you set a rejection counter to zero.
You remember incorrectly. My algorithm never rejects points.
Abigail
--
split // => '"';
${"@_"} = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_) {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};
------------------------------
Date: Wed, 24 Jan 2001 16:32:52 GMT
From: bobbybobbob@my-deja.com
Subject: RegEx: Removing spaces between tags
Message-Id: <94n03k$b1o$1@nnrp1.deja.com>
Greets,
I've been trying to figure out a regex for removing trailing spaces by
tags, to no avail.
I want to get rid of spaces to the left and to the right of a pattern
like this:
<some tag='fds'> Hello World </some>
^^^ ^^^
Any ideas, hints? I seem to fail at the "ignore <.*?>" parts. Thanks!
Bobby
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 24 Jan 2001 16:48:45 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: RegEx: Removing spaces between tags
Message-Id: <94n11d$k33$1@mamenchi.zrz.TU-Berlin.DE>
<bobbybobbob@my-deja.com> wrote in comp.lang.perl.misc:
>Greets,
>
>I've been trying to figure out a regex for removing trailing spaces by
>tags, to no avail.
>
>I want to get rid of spaces to the left and to the right of a pattern
>like this:
>
><some tag='fds'> Hello World </some>
> ^^^ ^^^
>
>Any ideas, hints? I seem to fail at the "ignore <.*?>" parts. Thanks!
Well, the "ignore <.*?>" part implies parsing HTML, no more, no less.
You can't do that with a simple regex. Use HTML::Parser (available
from CPAN if you don't have it) to parse out the text.
Anno
------------------------------
Date: Wed, 24 Jan 2001 18:17:37 GMT
From: bobbybobbob@my-deja.com
Subject: Re: RegEx: Removing spaces between tags
Message-Id: <94n67n$h48$1@nnrp1.deja.com>
> Well, the "ignore <.*?>" part implies parsing HTML, no more, no less.
> You can't do that with a simple regex. Use HTML::Parser (available
> from CPAN if you don't have it) to parse out the text.
To put the problem another way ... is there a way to trim off spaces to
the right of ">" and to the left of "<" with a simple regex?
Thanks!
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 24 Jan 2001 21:14:38 +0100
From: Tore Aursand <tore@extend.no>
Subject: Re: RegEx: Removing spaces between tags
Message-Id: <MPG.14d9561b9b395e3898985d@news.online.no>
In article <94n67n$h48$1@nnrp1.deja.com>, bobbybobbob@my-deja.com
says...
> To put the problem another way ... is there a way to trim off
> spaces to the right of ">" and to the left of "<" with a simple
> regex?
my $string = "<b> This is a test </b>";
$string =~ s/>\s+/>/g; # left
$string =~ s/\s+</</g; # right
I guess this can be done a much better way - and more fail-proof - but
at least it shows you the principles.
--
Tore Aursand - tore@extend.no - http://www.extend.no/~tore/
------------------------------
Date: Wed, 24 Jan 2001 20:29:32 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: RegEx: Removing spaces between tags
Message-Id: <slrn96u7mu.3sj.tadmc@tadmc26.august.net>
bobbybobbob@my-deja.com <bobbybobbob@my-deja.com> wrote:
>
>is there a way to trim off spaces to
>the right of ">" and to the left of "<" with a simple regex?
^
^
No, but there is a way with 2 simple pattern matches:
s/> +/>/g;
s/ +</</g;
(there is a way with a non-simple pattern match, but why bother?)
The Perl FAQ, part 9 gives many examples of legal HTML where that
can fail though. You are asking for trouble if you process HTML with
pattern matches. Use a module that understands HTML.
"How do I remove HTML from a string?"
e.g <img src='cool.jpg' alt=">> Cool pic! <<">
The code above will remove spaces that it should have left alone.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 24 Jan 2001 17:07:23 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: s/// inconsistency
Message-Id: <94n24b$hbt$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was NOT sent to Martien Verbruggen
<mgjv@tradingpost.com.au>],
who wrote in article <slrn96t2p2.n5q.mgjv@martien.heliotrope.home>:
> Ok. I suspect that you will have to accept a level of eval then. I'd go
> for the /ee options, but I would be very careful in what I accepted as
> user input for the right hand side of the substitution. Eval means that
> any perl code will be executed, and that can contain some nasties.
>
> If you follow Ilya's suggestion, and look at eg/rename in the perl
> distribution, you'll find that that program takes a full perl
> expression, which it evals for each argument. Eval might not be easy to
> avoid.
If you look at pfind, you find it differently. ;-) pfind evals to
define the "File::Find::wanted" subroutine, so it needs to do it only
once.
In my testing pfind was quickier than gnufind even when no external
programs were called. (?!)
Ilya
------------------------------
Date: Wed, 24 Jan 2001 21:17:07 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: spawning a process that is a perl program
Message-Id: <94ngo8$rnt$1@nnrp1.deja.com>
In article <3A6D0A88.83D1DAD5@stomp.stomp.tokyo>,
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
> Post actual code, post some factual data, post
> something with which people can analyze and work.
> It is not my intent to be rude but rather firm
> but fair. It is annoying to open an article which
> lacks any specific parameters and reliable info.
>
> Godzilla!
>
What? Okay, who's faking Moronzilla's messages?
amonotod
--
`\|||/ amonotod@
(@@) netscape.net
ooO_(_)_Ooo________________________________
_____|_____|_____|_____|_____|_____|_____|_____|
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 135
**************************************