[31281] in Perl-Users-Digest
Perl-Users Digest, Issue: 2526 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 22 21:09:46 2009
Date: Wed, 22 Jul 2009 18:09:11 -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 Wed, 22 Jul 2009 Volume: 11 Number: 2526
Today's topics:
Re: getting return value of external application on win <alfonso.baldaserra@gmail.com>
Re: How to avoid \x{...} when converting unicode to lat <blgl@hagernas.com>
Re: if .. then .. else shorthand problem <justin.0903@purestblue.com>
Re: if .. then .. else shorthand problem <uri@stemsystems.com>
Re: if .. then .. else shorthand problem <tzz@lifelogs.com>
Please suggest - Issue with comparing values <harpreet.noni@gmail.com>
Re: Please suggest - Issue with comparing values <smallpond@juno.com>
Re: should I force a install for DBD::mysql if tests fa <spamtrap@shermpendley.com>
Re: should I force a install for DBD::mysql if tests fa <ben@morrow.me.uk>
Re: should I force a install for DBD::mysql if tests fa <kkeller-usenet@wombat.san-francisco.ca.us>
Re: should I force a install for DBD::mysql if tests fa <nospam@nospam.invalid>
Re: should I force a install for DBD::mysql if tests fa <ben@morrow.me.uk>
Re: should I force a install for DBD::mysql if tests fa <kkeller-usenet@wombat.san-francisco.ca.us>
Re: SpreadSHeet::WriteExcel Error <justin.0903@purestblue.com>
Re: Which distro for windows? <sisyphus359@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 22 Jul 2009 05:25:17 -0700 (PDT)
From: alfonsobaldaserra <alfonso.baldaserra@gmail.com>
Subject: Re: getting return value of external application on win32
Message-Id: <5054411e-898f-4c53-8aac-c467c7a2df68@u16g2000pru.googlegroups.com>
> [code]
> use strict;
> use IPC::Run3;
> my ($stdout, $stderr);
> my @app =3D ('c:/program files/foo/flarp.exe', 'status', =A0'quux');
> run3(\@app, \undef, \$stdout, \$stderr);
> if ( $? =3D=3D 0 ) { print "yay"; }
> [/code]
i tried running this code. for some obscure reasons it was showing
unexpected results when using command as array, it wasn't executing
the program in background at all, so i did
my $app =3D q[ c:/program files/foo/flarp.exe status quux ];
and it started executing but there came another problem. the return
value ($?) was always 0 now. i tried the same code with other
commands and it was working just not for this particular program.
before i give up i want to thank you for making me aware of
IPC::Run3. plus i learnt that there exists a File::Spec->devnull() to
redirect $stdout and $stderr messages to.
many thanks.
------------------------------
Date: Wed, 22 Jul 2009 18:03:03 +0200
From: Bo Lindbergh <blgl@hagernas.com>
Subject: Re: How to avoid \x{...} when converting unicode to latin1?
Message-Id: <h47d7q$qtd$1@aioe.org>
In article <op.uxe9z2y3mk9oye@frodo>,
"Jochen Lehmeier" <OJZGSRPBZVCX@spammotel.com> wrote:
> Do you happen to know whether it is possible to change that replacement
> character from "?" to another one, as well?
Not easily. Setting $PerlIO::encoding::fallback to a coderef ought to work,
but it makes PerlIO::encoding do very strange things. You might have to
define your own encoding (see Encode::Encoding).
/Bo Lindbergh
------------------------------
Date: Wed, 22 Jul 2009 14:27:31 -0000
From: Justin C <justin.0903@purestblue.com>
Subject: Re: if .. then .. else shorthand problem
Message-Id: <45b8.4a6721d3.42cde@zem>
OK, I see the error of my ways. The bottom line, I think, to get the
result you expect, is to always use parens for that type of statement.
Thanks to B&B, JG, and Tony for the help.
Justin.
--
Justin C, by the sea.
------------------------------
Date: Wed, 22 Jul 2009 11:45:08 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: if .. then .. else shorthand problem
Message-Id: <87my6wd8mz.fsf@quad.sysarch.com>
>>>>> "JC" == Justin C <justin.0903@purestblue.com> writes:
JC> OK, I see the error of my ways. The bottom line, I think, to get the
JC> result you expect, is to always use parens for that type of statement.
nope. the bottom line is that you shouldn't do side effects with ?:. its
purpose is to return a value selected by a boolean test. the key word is
'return'. since perl allows side effects in expressions you are allowed
to put them inside ?: but it is very bad practice even if you use
parens. it is bypassing the purpose of the operator. if you want side
effects based upon a boolean, use if/else statements.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Wed, 22 Jul 2009 10:47:16 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: if .. then .. else shorthand problem
Message-Id: <87ab2wn2ij.fsf@lifelogs.com>
On Tue, 21 Jul 2009 14:21:26 -0000 Justin C <justin.0903@purestblue.com> wrote:
JC> I've only just started using the shorthand for the "if .. then .. else"
JC> statement: (test) ? this : or_that;
JC> Here's what I have:
JC> use strict;
JC> use warnings;
JC> my $weight = 40.18;
JC> my $half_kilos = (( int($weight) -30 ) * 2);
JC> print "$half_kilos\n";
JC> if ( (($weight - 30) - (int($weight) - 30)) != 0 ) {
JC> ( ($weight - int($weight)) < 0.5 ) ? $half_kilos += 1 : $half_kilos += 2;
JC> print "$half_kilos\n";
JC> }
JC> I expect $half_kilos to be 21. Failing that, 22. But I get 23!
JC> There's probably something really simple here I've not spotted, can
JC> someone please enlighten me? I admit that my example would be clearer
JC> written as a regular 'if...then...else', but I'd only just remembered
JC> these and had used one (in a simpler form), and wanted to drum it in, so
JC> used it again... I can remember how they work now... but can't get this
JC> one to work.
I think you need to look at rounding and try to formulate the
calculation in general math terms, not if-then-else statements. What
you're doing above is like using a rock to open the window.
Ted
------------------------------
Date: Wed, 22 Jul 2009 05:36:34 -0700 (PDT)
From: test <harpreet.noni@gmail.com>
Subject: Please suggest - Issue with comparing values
Message-Id: <c1ca84f3-794e-4aa1-90f6-0b7f5a00525d@r34g2000vba.googlegroups.com>
Greetings,
I have a perl file which is called from a ksh file. In this perl
script, I have to execute a procedure and get the output parameter.
this output paramtere(proces Date) needs to be compared with an input
parameter(run_date). If both dates are not same, I need to exit out of
the job. However, when I am trying to execute the procedure and
capture the value, it always returns 0. I am unable o capture this
date output and compare it with the input date. I am using DBI for
connectivity.
Below is the SAMPLE script. Can you please advise
my $sth;
$db_handle = &connectDB($server, $user, $password, $database);
my $extract_sql;
my $date_cmp_sql ;
$date_cmp_sql = "
DECLARE \@ReportDate DATETIME,
\@ProcessDate DATETIME
SELECT \@ReportDate ='$report_date'
EXEC $db_name..GetPriorDate 1, \@ReportDate, \@ProcessDate output
SELECT \@ProcessDate
";
my $st;
$st = $db_handle->prepare("$date_cmp_sql") or die("Could not prepare
for SQL statement");
$st->execute() or die localtime(time). " ---Can't excute SQL
statement: $DBI::errstr\n";
$err_str=$db_handle->errstr;
$err_no=$db_handle->err;
if ($err_str ne "")
{
print(" error \n");
exit 1;
}
my @RptFlag = ();
@RptFlag = $st->fetchrow_array() ;
my $RprtGenrFlag = $RptFlag[0];
print("RprtGenrFlag is $RprtGenrFlag \n\n");
##if ($Report_date eq "0")
$run_date = $RprtGenrFlag;
print("run_date is $run_date");
if($RprtGenrFlag eq $run_date)
{
print("two dates are equal \n");
}
else
{
print("dates are not equal \n");
}
$st->finish();
&disconnectDB ($db_handle, $server);
------------------------------
Date: Wed, 22 Jul 2009 13:42:39 -0400
From: Steve C <smallpond@juno.com>
Subject: Re: Please suggest - Issue with comparing values
Message-Id: <h47jfa$rd0$1@news.eternal-september.org>
test wrote:
> Greetings,
>
> I have a perl file which is called from a ksh file. In this perl
> script, I have to execute a procedure and get the output parameter.
> this output paramtere(proces Date) needs to be compared with an input
> parameter(run_date). If both dates are not same, I need to exit out of
> the job. However, when I am trying to execute the procedure and
> capture the value, it always returns 0. I am unable o capture this
> date output and compare it with the input date. I am using DBI for
> connectivity.
>
> Below is the SAMPLE script. Can you please advise
>
> my $sth;
>
>
> $db_handle = &connectDB($server, $user, $password, $database);
>
> my $extract_sql;
> my $date_cmp_sql ;
>
> $date_cmp_sql = "
> DECLARE \@ReportDate DATETIME,
> \@ProcessDate DATETIME
>
> SELECT \@ReportDate ='$report_date'
>
Is SQL picky about spaces after '='? I think it's good practice.
> EXEC $db_name..GetPriorDate 1, \@ReportDate, \@ProcessDate output
> SELECT \@ProcessDate
> ";
> my $st;
> $st = $db_handle->prepare("$date_cmp_sql") or die("Could not prepare
> for SQL statement");
>
> $st->execute() or die localtime(time). " ---Can't excute SQL
> statement: $DBI::errstr\n";
> $err_str=$db_handle->errstr;
> $err_no=$db_handle->err;
>
> if ($err_str ne "")
> {
> print(" error \n");
> exit 1;
> }
>
> my @RptFlag = ();
> @RptFlag = $st->fetchrow_array() ;
>
I wonder if $#RptFlag is -1 right here?
> my $RprtGenrFlag = $RptFlag[0];
>
> print("RprtGenrFlag is $RprtGenrFlag \n\n");
>
>
> ##if ($Report_date eq "0")
> $run_date = $RprtGenrFlag;
> print("run_date is $run_date");
> if($RprtGenrFlag eq $run_date)
> {
> print("two dates are equal \n");
> }
> else
> {
> print("dates are not equal \n");
> }
>
> $st->finish();
> &disconnectDB ($db_handle, $server);
>
------------------------------
Date: Wed, 22 Jul 2009 15:17:29 -0400
From: Sherm <spamtrap@shermpendley.com>
Subject: Re: should I force a install for DBD::mysql if tests fail?
Message-Id: <m2ljmgbk8m.fsf@dot-app.org>
Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us> writes:
> I don't know if there is a way to
> pass these parameters though from within CPAN; it'd be nice if there
> were.)
There is. In the CPAN shell, "look DBD::mysql" will download and unzip
the tarball, and open up a subshell in the build directory.
sherm--
------------------------------
Date: Wed, 22 Jul 2009 21:02:48 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: should I force a install for DBD::mysql if tests fail?
Message-Id: <8s7kj6-rmr.ln1@osiris.mauzo.dyndns.org>
Quoth Sherm <spamtrap@shermpendley.com>:
> Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us> writes:
>
> > I don't know if there is a way to
> > pass these parameters though from within CPAN; it'd be nice if there
> > were.)
>
> There is. In the CPAN shell, "look DBD::mysql" will download and unzip
> the tarball, and open up a subshell in the build directory.
That's a poor workaround. DBD::mysql may be a long way up the dependancy
chain from the module the user is actually trying to install.
It's generally considered bad practice nowadays for a distribution to
require any manual intervention to install.
Ben
------------------------------
Date: Wed, 22 Jul 2009 13:28:00 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: should I force a install for DBD::mysql if tests fail?
Message-Id: <gb9kj6xlp7.ln2@goaway.wombat.san-francisco.ca.us>
On 2009-07-22, Ben Morrow <ben@morrow.me.uk> wrote:
>
> That's a poor workaround. DBD::mysql may be a long way up the dependancy
> chain from the module the user is actually trying to install.
>
> It's generally considered bad practice nowadays for a distribution to
> require any manual intervention to install.
How else would you configure testing in an arbitrary MySQL environment?
Any default username/password/dbname combination is sure not to work in
many environments, not to mention dbhost. So, either you're stuck with
not doing any of the live db tests, or you need a way to configure them.
Or you ignore the results of the live tests if in CPAN, or tell users to
force install DBD::mysql. But neither of those seem best practice.
--keith
--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information
------------------------------
Date: Wed, 22 Jul 2009 20:59:40 +0000 (UTC)
From: Rahul <nospam@nospam.invalid>
Subject: Re: should I force a install for DBD::mysql if tests fail?
Message-Id: <Xns9C50A2B5760646650A1FC0D7811DDBC81@85.214.113.135>
Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us> wrote in
news:gb9kj6xlp7.ln2@goaway.wombat.san-francisco.ca.us:
> How else would you configure testing in an arbitrary MySQL environment?
> Any default username/password/dbname combination is sure not to work in
> many environments, not to mention dbhost. So, either you're stuck with
> not doing any of the live db tests, or you need a way to configure them.
> Or you ignore the results of the live tests if in CPAN, or tell users to
> force install DBD::mysql. But neither of those seem best practice.
>
Maybe tell users to add a specific user/pw to mysql with very limited
permissions on a test db. Thats what I ended up doing. There were some
instructions but I missed them in the lots of scrolling output. Maybe if
CPAN stopped there for a user input.
--
Rahul
------------------------------
Date: Wed, 22 Jul 2009 22:56:24 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: should I force a install for DBD::mysql if tests fail?
Message-Id: <8hekj6-94s.ln1@osiris.mauzo.dyndns.org>
Quoth Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>:
> On 2009-07-22, Ben Morrow <ben@morrow.me.uk> wrote:
> >
> > That's a poor workaround. DBD::mysql may be a long way up the dependancy
> > chain from the module the user is actually trying to install.
> >
> > It's generally considered bad practice nowadays for a distribution to
> > require any manual intervention to install.
>
> How else would you configure testing in an arbitrary MySQL environment?
> Any default username/password/dbname combination is sure not to work in
> many environments, not to mention dbhost. So, either you're stuck with
> not doing any of the live db tests, or you need a way to configure them.
The correct answer is 'as part of the tests, run a daemon on an
unprivileged port on localhost that knows how to talk enough of the
MySQL protocol to test the library'. This is generally nowhere near as
hard as it sounds: the test daemon doesn't have to actually implement a
RDBMS, just check it gets the expected requests and send appropriate
canned responses. It's likely that many of the bits of the module that
actually need testing--that is, the bits that aren't simply wrappers
around the MySQL client library, which we can assume works
correctly--don't need to talk to the network at all.
Alternatively, if the machine we are installing on has the MySQL server
components installed, it would likely be possible to create an
appropriate configuration file and temporary storage area and run a
fresh instance of the real database daemon on an unprivileged port.
In any case, tests which cannot be run (for whatever reason) in the
current environment should be skipped, not simply allowed to fail.
Documenting 'if you have problems with this module, please set up <this>
on your database and rerun the tests with <that> in the environment' is
fine, but requiring user intervention to just get the module installed
is not.
Ben
------------------------------
Date: Wed, 22 Jul 2009 15:10:17 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: should I force a install for DBD::mysql if tests fail?
Message-Id: <9bfkj6xli9.ln2@goaway.wombat.san-francisco.ca.us>
On 2009-07-22, Rahul <nospam@nospam.invalid> wrote:
>
> Maybe tell users to add a specific user/pw to mysql with very limited
> permissions on a test db.
End-users may not have the authority to make those changes, and may be
turned down by a DBA who doesn't want to cooperate.
> Maybe if CPAN stopped there for a user input.
DBD::mysql doesn't ask for user input, so CPAN can't stop to ask for it.
The parameters are provided on the command line for perl Makefile.PL. I
don't currently see a way to provide this to (e.g.) install DBD::mysql
from within CPAN.
Bioperl does have a series of prompts when you run perl Makefile.PL;
perhaps adding those to the build for DBD::mysql is a reasonable
compromise. But that would need to be done by those developers, it's
not something that CPAN controls.
--keith
--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information
------------------------------
Date: Wed, 22 Jul 2009 14:46:00 -0000
From: Justin C <justin.0903@purestblue.com>
Subject: Re: SpreadSHeet::WriteExcel Error
Message-Id: <4690.4a672628.c64f7@zem>
On 2009-07-21, Rajpreet <rajpreetsidhu@gmail.com> wrote:
> Greetings,
>
> I am trying to generate an excel report using perl. However, I am
> getting below error. Below is the sample file and error quote. Can any
> one suggest something?
use warnings;
use strict;
I fixed the error and the code worked for me.
Justin.
--
Justin C, by the sea.
------------------------------
Date: Wed, 22 Jul 2009 01:48:41 -0700 (PDT)
From: sisyphus <sisyphus359@gmail.com>
Subject: Re: Which distro for windows?
Message-Id: <f19b5b16-5353-427f-9030-2b2baf8065e7@m7g2000prd.googlegroups.com>
On Jul 22, 1:44=A0am, Bernie Cosell <ber...@fantasyfarm.com> wrote:
> I *think* that with Activestate you can only install prebuilt stuff
> from repositories
No - you can install from CPAN source. To install perl extensions
(modules that contain xs code) you'll need a C compiler.
Strawberry ships with the MinGW compiler, but with ActivePerl you'll
have to 'ppm install MinGW' or separately install a Microsoft Compiler
(preferably MSVC++ 6.0).
I find it hard to pick between Strawberry Perl and ActivePerl on
purely rational grounds ... my advice is to just go with the one that
you want to.
Cheers,
Rob
------------------------------
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 V11 Issue 2526
***************************************