[21980] in Perl-Users-Digest
Perl-Users Digest, Issue: 4202 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Dec 1 18:05:39 2002
Date: Sun, 1 Dec 2002 15:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 1 Dec 2002 Volume: 10 Number: 4202
Today's topics:
Re: anyone compile perl on linux? <heitkamp@ameritech.net>
Re: Changing the width of the tab <stevenm@blackwater-pacific.com>
Re: DBI-Performance Problem <goldbb2@earthlink.net>
disable Unicode in Perl 5.8 ? <andi@my.home>
Re: disable Unicode in Perl 5.8 ? <goldbb2@earthlink.net>
Re: help with regexp: exclude \. from the \w group? <goldbb2@earthlink.net>
How to consider ampersands in a URL as non-spec. charac <mario@rossi1.com>
Re: How to consider ampersands in a URL as non-spec. ch <stevenm@blackwater-pacific.com>
Re: How to consider ampersands in a URL as non-spec. ch <bwalton@rochester.rr.com>
Re: How to place entire commnad line argument list into <holland@origo.phys.au.dk>
How to place entire commnad line argument list into a s <chuckycarson@networkcloud.com>
Re: How to place entire commnad line argument list into <tony_curtis32@yahoo.com>
sendmail: Email could not be delivered too ...? <pubari@regenbogenweg.de>
Re: sendmail: Email could not be delivered too ...? <spam@thecouch.homeip.net>
Re: sendmail: Email could not be delivered too ...? <nobody@dev.null>
Re: sendmail: Email could not be delivered too ...? (David Efflandt)
Re: Windows multiple process questions with either Win3 <goldbb2@earthlink.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 01 Dec 2002 21:47:19 GMT
From: Fred Heitkamp <heitkamp@ameritech.net>
Subject: Re: anyone compile perl on linux?
Message-Id: <Pine.LNX.4.43.0212011547120.1897-100000@pc1.fred.org>
On Sat, 30 Nov 2002, Benjamin Goldberg wrote:
> heitkamp@ameritech.net wrote:
>
> This isn't really the best place to post this kind of problem -- send it
> to the perl5porters mailing list using the 'perlbug' program which comes
> with perl, or mail directly to perl5-porters@perl.org.
Thanks for the info. I think I discovered part of the problem
on my own. (as usual, posting a cry for help often triggers
the solution.)
Fred
Error Loading Explorer.exe
You must reinstall Windows.
------------------------------
Date: Sun, 01 Dec 2002 11:50:18 -0800
From: Steven May <stevenm@blackwater-pacific.com>
Subject: Re: Changing the width of the tab
Message-Id: <asdoru$srp$1@quark.scn.rain.com>
AG wrote:
> I am trying to output a table of 2 columns using /t formatting:
>
> However, if the length of the word if the first column exceeds 7
> characters, the next column is pushed further then the rest. Which
> leads me to my question:
>
> Is there a way to change the default width of columns from 8 to ,say,
> 12 characters?
>
> Thank you
You might look at the functions format and formline.
s.
------------------------------
Date: Sun, 01 Dec 2002 17:53:05 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: DBI-Performance Problem
Message-Id: <3DEA92D1.E9F0AC6E@earthlink.net>
Henning Meyer wrote:
>
> Hello,
>
> I use Perl 5.6.0, DBI 1.30 and DBD-Oracle 1.12.
> While checking the performance, my Oracle-Tools discovered, that the
> Database does two prepares for every execute.
The first thing to do is see if you can make your oracle-tools thingy
print out precisely *when* each prepare and each execute occurs.
I've never used Oracle tools, so I don't know if it's possible.
> My Perl-Code looks like this:
>
> my $cur=$dbh->prepare($call);
> die "Prepare-Error: $DBI::err\n$call\n$DBI::errstr\n" if
> ($DBI::err);
Put a print statement before this prepare, and one after.
That way, we can see if this $dbh->prepare actually does one prepare or
two on the Oracle server end.
> $cur->execute(@$vars);
> die "Execute-Error: $DBI::err\n$call\n$DBI::errstr\n" if
> ($DBI::err);
Put a print statement before this execute, and after.
The execute ought not be doing any prepares, of course, and if it does,
then something's wrong.
> my @res=();
> while (my $href=$cur->fetchrow_hashref) {
> die "Fetch-Error: $DBI::err\n$call\n$DBI::errstr\n" if
> ($DBI::err);
This die statement is never reached, since we wouldn't be inside this
loop unless the fetch failed.
> for(keys %$href) {
> $href->{$_}=~s/[\s]*$//;
> $href->{$_}=~s/^[\s]//;
> }
This would be better written as:
s/^\s*//, s/\s*\z//
for @{$href}{keys %$href};
This avoids having to access $href more often than necessary.
> push(@res,$href);
Uhh, you *have* read the DBI docs, haven't you?
Every time that fetchrow_hashref returns, it give you the *same* hash
reference (but with different data filled in, each time). As a result,
your @res will simply have one hashref repeated multiple times. Oops.
What you want instead is:
push @res, { %$href };
Which makes a new anonymous hashref containing a copy of %$href.
> }
> $cur->finish;
This is unnecessary, unless you exit the while(...fetch) loop before
fetching all of the rows of data.
> return(\@res);
>
> How could it be, that there is an prepare/execute ratio of 2?
>
> I have execute much equal statements with bind-Values, and its very
> annoying that there are 400 prepares for 200 executes instead of one
> prepare.
>
> Any hints?
Perhaps some other part of your code is doing prepares?
Also, what happens if you change from ->prepare to ->prepare_cached ?
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Sun, 01 Dec 2002 18:23:18 +0100
From: "Andreas Gohr" <andi@my.home>
Subject: disable Unicode in Perl 5.8 ?
Message-Id: <pan.2002.12.01.17.23.17.214467@my.home>
Hi all!
I have a problem with the new unicode behaviour of Perl 5.8. I've read
already the perldocs perluniintro and perlunicode as well as the Perl
Locale and Unicode FAQ but I found no way to completely disable the new
internal string representation as unicode. I have to insert some values
into a MySQL database and need all strings to be always latin1. The
program is supposed to run in Perl 5.6 _and_ Perl 5.8 (and maybe in Perl
5.004 too) and I need a way to behave always the same.
Do you have any tips for me?
Andi
------------------------------
Date: Sun, 01 Dec 2002 18:05:02 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: disable Unicode in Perl 5.8 ?
Message-Id: <3DEA959E.EDF3F42@earthlink.net>
Andreas Gohr wrote:
>
> Hi all!
>
> I have a problem with the new unicode behaviour of Perl 5.8. I've read
> already the perldocs perluniintro and perlunicode as well as the Perl
> Locale and Unicode FAQ but I found no way to completely disable the
> new internal string representation as unicode.
That's ok. You wouldn't really want to do that, anyway.
> I have to insert some values into a MySQL database and need all
> strings to be always latin1.
Umm, why not use the Encode module to convert your strings to latin1?
Or better yet, avoid producing utf8 strings in the first place.
> The program is supposed to run in Perl 5.6 _and_ Perl 5.8 (and maybe
> in Perl 5.004 too) and I need a way to behave always the same.
> Do you have any tips for me?
Don't store data in your strings with character values > 256?
Perl doesn't use utf8 encoding unless it *needs* to. If the chars of
your data are all <= 255, then perl will use bytes. It will upgrade
when necessary, but not otherwise.
Once it *has* upgraded data to utf8, then of course you may need to
force it to downgrade it before storing it in your database... but if
your database is will-designed, it will do it for you.
(There are also some functions in the utf8:: namespace which may help).
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Sun, 01 Dec 2002 17:40:16 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: help with regexp: exclude \. from the \w group?
Message-Id: <3DEA8FD0.E14739C3@earthlink.net>
Kevin Howe wrote:
[snip]
Assuming you mean, exclude \. from the \W group...
The normal meaning of /\W/ is /[^\w]/
To create something like /\W/ but without /\./, try /[^\w.]/.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Sun, 1 Dec 2002 20:07:09 +0100
From: "Mario Rossi" <mario@rossi1.com>
Subject: How to consider ampersands in a URL as non-spec. characters
Message-Id: <asdmn0$9qn$1@lacerta.tiscalinet.it>
(sorry for the bad english)
How can I, in a general URL, insert a parameter that contains as value
another url with other parameters/ampersands in it distinguishing this last
parameters from those of the general URL (considering them as a simple
text)?
In the example below (that doesn't work) I would that the:
"srv, action, url, userID, password" parameters to be for the prog1.cgi
program
and that the "formtype, query" parameters to be considered as text (they
will be used for the url address as prog2.cgi program parameters):
http://www.test.it/prog1.cgi?srv=log&action=Log&url=http://www.pippo.it/prog
2.cgi?formtye=advanced&query=casa&userID=agneli&password=ciao
Writing it in this way it believes that all the parameters of the prog2.cgi
(&formtype, &query) are for the prog1.cgi.
NOTE: I cannot modify the cgi programs because they're not mine. I only
have/can to find the URL syntax to do solve this problem.
------------------------------
Date: Sun, 01 Dec 2002 12:05:38 -0800
From: Steven May <stevenm@blackwater-pacific.com>
Subject: Re: How to consider ampersands in a URL as non-spec. characters
Message-Id: <asdpol$14n$1@quark.scn.rain.com>
Mario Rossi wrote:
> (sorry for the bad english)
>
> How can I, in a general URL, insert a parameter that contains as value
^^^^^^^^^^^^^^^^^^
So you are generating the query string...
> another url with other parameters/ampersands in it distinguishing this last
> parameters from those of the general URL (considering them as a simple
> text)?
>
> In the example below (that doesn't work) I would that the:
> "srv, action, url, userID, password" parameters to be for the prog1.cgi
> program
> and that the "formtype, query" parameters to be considered as text (they
> will be used for the url address as prog2.cgi program parameters):
>
> http://www.test.it/prog1.cgi?srv=log&action=Log&url=http://www.pippo.it/prog
> 2.cgi?formtye=advanced&query=casa&userID=agneli&password=ciao
>
> Writing it in this way it believes that all the parameters of the prog2.cgi
> (&formtype, &query) are for the prog1.cgi.
>
As I would expect it to do...
> NOTE: I cannot modify the cgi programs because they're not mine. I only
> have/can to find the URL syntax to do solve this problem.
>
>
You are not escaping the value for url.
There are undoubtedly better ways, but you could do something like:
# untested #
#! /usr/bin/perl -w
use strict;
my $url = 'http://www.pippo.it/prog
2.cgi?formtye=advanced&query=casa&userID=agneli&password=ciao';
$url = &escape_query( $url );
my $link = "http://www.test.it/prog1.cgi?srv=log&action=Log&url=$url";
print "Content-type: text/html\n\n";
print $link;
#-----------SUB escape_query ----------------#
sub escape_query {
my $query = shift;
$query =~ s/([^a-zA-Z0-9_.-])/uc sprintf("%%%02x",ord($1))/eg;
return $query;
} # end of sub escape_query
As an 'oh, by the way', passing usernames and passwords in urls is not a
good thing. I would strongly recommend you investigate other ways of
maintaining state.
hth,
s.
------------------------------
Date: Sun, 01 Dec 2002 20:13:42 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: How to consider ampersands in a URL as non-spec. characters
Message-Id: <3DEA6D31.1020503@rochester.rr.com>
Mario Rossi wrote:
...
> How can I, in a general URL, insert a parameter that contains as value
> another url with other parameters/ampersands in it distinguishing this last
> parameters from those of the general URL (considering them as a simple
> text)?
>
> In the example below (that doesn't work) I would that the:
> "srv, action, url, userID, password" parameters to be for the prog1.cgi
> program
> and that the "formtype, query" parameters to be considered as text (they
> will be used for the url address as prog2.cgi program parameters):
>
> http://www.test.it/prog1.cgi?srv=log&action=Log&url=http://www.pippo.it/prog
> 2.cgi?formtye=advanced&query=casa&userID=agneli&password=ciao
>
> Writing it in this way it believes that all the parameters of the prog2.cgi
> (&formtype, &query) are for the prog1.cgi.
>
> NOTE: I cannot modify the cgi programs because they're not mine. I only
> have/can to find the URL syntax to do solve this problem.
>
>
>
You've got the wrong newsgroup. This newsgroup is for the discussion of
the Perl programming language, not for discussion of URL formatting.
But nonetheless -- you will need to escape any special characters in a
URL which you don't want interpreted as special characters in the URL.
You can escape any ASCII character in a URL by replacing it with the
sequence %xx , where "xx" is a hexadecimal number giving the collating
sequence number of that character in the ASCII character set. For
example, a space character may be escaped by replacing it with %20 . In
your case, you will subsequently need to escape the %'s to suppress the
interpretation of the escaped characters the first time through. You
probably want something like [untested]:
http://www.test.it/prog1.cgi?srv=log&action=Log&url=http://www.pippo.it/prog2.cgi%253fformtype%253dadvanced%2526query%253dcasa&userID=agneli&password=ciao
The second time the above is URL-decoded, it should give the desired result.
--
Bob Walton
------------------------------
Date: 01 Dec 2002 22:07:30 +0100
From: Steve Holland <holland@origo.phys.au.dk>
Subject: Re: How to place entire commnad line argument list into a single string variable
Message-Id: <w47r8d1phwt.fsf@origo.phys.au.dk>
Chuckster <chuckycarson@networkcloud.com> writes:
> I have a perl script that expects a SQL query as it's command line
> argument. I want to place the entire command line argument into a
> single string. It there an easy way of doing this other than
> checking the length of @ARGV and then building a string in a
> while/for loop?
You can do it in one line with a foreach loop if you ignore error
checking.
#! /usr/local/bin/perl
use strict;
use warnings;
print "@ARGV\n";
my $string = "";
$string .= $_ foreach (@ARGV);
print "$string\n";
==========================================================================
To find out who and where I am look at:
http://www.nd.edu/~sholland/index.html
"Only so many songs can be sung with two lips, two lungs, and one tounge."
==========================================================================
------------------------------
Date: Sun, 01 Dec 2002 12:43:02 -0800
From: Chuckster <chuckycarson@networkcloud.com>
Subject: How to place entire commnad line argument list into a single string variable
Message-Id: <3DEA7456.10401@networkcloud.com>
I have a perl script that expects a SQL query as it's command line
argument. I want to place the entire command line argument into a single
string. It there an easy way of doing this other than checking the
length of @ARGV and then building a string in a while/for loop?
Thx,
CC
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
------------------------------
Date: Sun, 01 Dec 2002 15:11:27 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: How to place entire commnad line argument list into a single string variable
Message-Id: <87vg2da1hc.fsf@limey.hpcc.uh.edu>
>> On Sun, 01 Dec 2002 12:43:02 -0800,
>> Chuckster <chuckycarson@networkcloud.com> said:
> I have a perl script that expects a SQL query as it's
> command line argument. I want to place the entire
> command line argument into a single string. It there an
> easy way of doing this other than checking the length of
> @ARGV and then building a string in a while/for loop?
Simplest just to stringify it:
my $command_line = "@ARGV";
Alternatively you can join() the elements of @ARGV if you
need a specific separator between elements.
------------------------------
Date: Sun, 1 Dec 2002 18:05:52 +0000 (UTC)
From: "Guido Hörnschemeyer" <pubari@regenbogenweg.de>
Subject: sendmail: Email could not be delivered too ...?
Message-Id: <4cc077ab1ba11fa9ae25ce0e80662f69.115891@mygate.mailgate.org>
HiHo!
How could I find out, if an email could not be sent to one of the
recipients (because the email is not valid) using sendmail?
--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
------------------------------
Date: Sun, 01 Dec 2002 13:34:27 -0500
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: sendmail: Email could not be delivered too ...?
Message-Id: <3DEA5633.9070201@thecouch.homeip.net>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Guido Hörnschemeyer wrote:
| HiHo!
|
| How could I find out, if an email could not be sent to one of the
| recipients (because the email is not valid) using sendmail?
If you delivered the email to the sendmail on the local machine, and
sendmail is configured to act as a normal MTA (not a smarthost), then
you'll be able to see the statuses of the messages by grabbing the
output from the command "mailq".
Alternatively, check http://search.cpan.org . There are modules there
that you can use instead of sendmail (yes, a perl MTA) that you might be
able to immediately get the results of.
Another option is to use something I wrote several years ago, I posted
it at :
http://groups.google.com/groups?selm=3D40D86D.9030903%40thecouch.homeip.net
This will allow you to validate an email address before shipping it off
to the MTA. Note that if you're trying to learn perl, the above isn't
exactly "prestine" code. I whipped it up in a hurry.
Best of luck.
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE96lYzeS99pGMif6wRAsvRAJ9juIfyyEg8kXyaegewYJKatMWOOwCeKKRn
eeLxACXOUbvQZbdexxEAImU=
=nAPV
-----END PGP SIGNATURE-----
------------------------------
Date: Sun, 01 Dec 2002 18:53:53 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: sendmail: Email could not be delivered too ...?
Message-Id: <3DEA5A64.9030103@dev.null>
Guido Hörnschemeyer wrote:
> HiHo!
>
> How could I find out, if an email could not be sent to one of the
> recipients (because the email is not valid) using sendmail?
Would the Mail::Checkuser module (available on CPAN) work for you?
------------------------------
Date: Sun, 1 Dec 2002 22:02:33 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: sendmail: Email could not be delivered too ...?
Message-Id: <slrnaul1no.3fd.efflandt@typhoon.xnet.com>
On Sun, 1 Dec 2002, Guido Hörnschemeyer <pubari@regenbogenweg.de> wrote:
> How could I find out, if an email could not be sent to one of the
> recipients (because the email is not valid) using sendmail?
You can do prelimiary checks to see if it is formatted as an e-mail
address (just realize that a domain can contain a hyphen). But the only
true way to check if an address is valid and active is to send it as a
valid user that can receive mail or with valid From: or Reply-To; and ask
the user to reply. If you get a bounce error it is invalid, if you get a
reply it is valid, otherwise it fell through a filter or someone
does not check their mail often or they didn't care to reply.
--
David Efflandt - All spam ignored http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Sun, 01 Dec 2002 17:37:55 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Windows multiple process questions with either Win32:Process or "Start"
Message-Id: <3DEA8F42.824C2DDF@earthlink.net>
Mark wrote:
>
> I have a perl script that will download one file at a time from my ftp
> program. I want to be able to download multiple files at once and
> when all of the files have completed downloading, then run the rest of
> my perl script with the rest of my utilities. I have used "start
> myprogram" to download mulitple files at once, but I do not know how
> to make Perl wait on the programs to finish downloading so I can then
> run other utilities from my one perl script.
The problem with "start" is that you cannot decide to wait for the other
process to run to completion.
I would instead suggest:
use Win32::Process;
my @tasks;
foreach my $argument (@programs) {
if( Win32::Process::Create(
my($process),
"program command line $argument",
"C:/path/to/program",
0, NORMAL_PRIORITY_CLASS,
"C:/path/for/program's/CWD", # usually you'd use "."
) ) {
push @tasks, [$process, $argument];
next;
}
my $error = $^E;
for my $task (@tasks) {
my ($proc, $file) = @$task;
$proc->Kill(0);
unlink $file;
}
die "Error creating process: $error";
}
# All processes are now running, in parallel.
# If you want to do other stuff while waiting for the downloads to
# complete, do it here.
# Now, wait for each of them to finish.
foreach my $task (@tasks) {
my ($process, $file) = @$task;
$process->Wait(INFINITE);
$process->GetExitCode(my $exitcode);
if( $exitcode ) {
warn "Download of file $file exited with code $exitcode\n";
# unlink $file;
}
}
> I tried:
>
> until (-e myfile){
>
> but it did not work either.
>
> I have looked at Win32::Process, but I am not sure that it will make
> the rest of my script wait until my files are downloaded. Thanks for
> any help anyone could give.
No, it should not make you wait, except precisely when you tell it to
wait.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
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 4202
***************************************