[31280] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2525 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 21 21:09:45 2009

Date: Tue, 21 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           Tue, 21 Jul 2009     Volume: 11 Number: 2525

Today's topics:
    Re: create directory in other domain <stoupa@practisoft.cz>
    Re: How to avoid \x{...} when converting unicode to lat <ben@morrow.me.uk>
    Re: How to avoid \x{...} when converting unicode to lat <blgl@hagernas.com>
    Re: How to avoid \x{...} when converting unicode to lat <OJZGSRPBZVCX@spammotel.com>
        if .. then .. else shorthand problem <justin.0903@purestblue.com>
    Re: if .. then .. else shorthand problem <glex_no-spam@qwest-spam-no.invalid>
    Re: if .. then .. else shorthand problem <No_4@dsl.pipex.com>
    Re: if .. then .. else shorthand problem <tony_curtis32@yahoo.com>
        should I force a install for DBD::mysql if tests fail? <nospam@nospam.invalid>
    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 <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 <nospam@nospam.invalid>
    Re: SpreadSHeet::WriteExcel Error <derykus@gmail.com>
        Which distro for windows? <bernie@fantasyfarm.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 22 Jul 2009 00:50:10 +0200
From: "Petr Vileta \"fidokomik\"" <stoupa@practisoft.cz>
Subject: Re: create directory in other domain
Message-Id: <h45goo$2hnj$1@ns.felk.cvut.cz>

Andrey wrote:
>>> I have 2 sites in same server (it is dedicated one not shared)
>>
>>> I need to create a directory in one site by using perl-script on
>>> other site.
>>
>>> Then I try to create a new directory I got error "Permission
>>> denied". But then I try to create directory in same directory it
>>> works fine. (Parent's directory access is OK 0777 )
>>
>> Could it be that the two different domains are run by two different
>> system users ?
>>
> Yes, these domains are run by two different users.

When domain 1 is running under user say "web1" and domain 2 under user "web2" 
then you can add user "web2" as member of group "web1" and vice-versa. In other 
words:

group    members
--------------------------
web1    web1, web2
web2    web2, web1

-- 
Petr Vileta, Czech Republic
(My server rejects all messages from Yahoo and Hotmail.
Send me your mail from another non-spammer site please.)
Please reply to <petr AT practisoft DOT cz>



------------------------------

Date: Tue, 21 Jul 2009 14:25:48 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: How to avoid \x{...} when converting unicode to latin1?
Message-Id: <s7sgj6-tl8.ln1@osiris.mauzo.dyndns.org>


Quoth "Jochen Lehmeier" <OJZGSRPBZVCX@spammotel.com>:
> 
> here is a test script that outputs a unicode string which cannot be  
> represented in latin1 to a latin1-encoded file:
> 
> 	my $unicode="hello \x{010d} world";
> 	binmode STDOUT,":encoding(latin1)";
> 	print $unicode,"\n";
> 	
> The output of Perl 5.8.8 is:
> 
> 	"\x{010d}" does not map to iso-8859-1 at test.pl line 3.
> 	hello \x{010d} world
> 	
> So far so good. The output is perfectly fine, as expected.
> 
> Is there a way to achieve the output "hello ? world" instead? Having  

See $PerlIO::encoding::fallback in perldoc PerlIO::encoding, and
"Handling Malformed Data" in perldoc Encode.

Ben



------------------------------

Date: Tue, 21 Jul 2009 15:57:55 +0200
From: Bo Lindbergh <blgl@hagernas.com>
Subject: Re: How to avoid \x{...} when converting unicode to latin1?
Message-Id: <h44hh8$pqr$1@aioe.org>

Read the documentation for PerlIO::encoding and note the part about
$PerlIO::encoding::fallback.  You clear the PERLQQ bit like this:

    use PerlIO::encoding;

    $PerlIO::encoding::fallback &= ~ Encode::PERLQQ();
    binmode(STDOUT, ":encoding(iso-latin-1)");
    print "Hello, World!\x{2122}\n";

If you want to silence the warning, clear the WARN_ON_ERR bit as well:

    $PerlIO::encoding::fallback &=
      ~ (Encode::PERLQQ() | Encode::WARN_ON_ERR());


/Bo Lindbergh


------------------------------

Date: Tue, 21 Jul 2009 16:46:40 +0200
From: "Jochen Lehmeier" <OJZGSRPBZVCX@spammotel.com>
Subject: Re: How to avoid \x{...} when converting unicode to latin1?
Message-Id: <op.uxe9z2y3mk9oye@frodo>

On Tue, 21 Jul 2009 15:57:55 +0200, Bo Lindbergh <blgl@hagernas.com> wrote:

> Read the documentation for PerlIO::encoding and note the part about
> $PerlIO::encoding::fallback.

I did notice that part, but the documentation is quite terse around that  
topic; as far as I can tell it is not possible to arrive at your solution  
 from there. The PERLQQ and other constants seem to be documented in Encode  
(albeit as "Encode::FB_PERLQQ", not "Encode::PERLQQ()", and in the  
Malformed Data chapter - my problem is not related to malformed data at  
all) while $PerlIO::encoding::fallback is mentioned in the very short  
PerlIO::encoding. Neither place mentions the other, as far as I can tell.

If whoever maintains that documentation reads this - maybe you could add  
Bo's example in the appropriate place. Not complaining, just pointing out  
a source for trouble.

> You clear the PERLQQ bit like this:
>     $PerlIO::encoding::fallback &= ~ Encode::PERLQQ();

Awesome - problem solved.

> If you want to silence the warning, clear the WARN_ON_ERR bit as well:
>
>     $PerlIO::encoding::fallback &=
>       ~ (Encode::PERLQQ() | Encode::WARN_ON_ERR());

Aye, useful.

Do you happen to know whether it is possible to change that replacement  
character from "?" to another one, as well?

Thank you!


------------------------------

Date: Tue, 21 Jul 2009 14:21:26 -0000
From: Justin C <justin.0903@purestblue.com>
Subject: if .. then .. else shorthand problem
Message-Id: <2a20.4a65cee6.826b8@zem>


I've only just started using the shorthand for the "if .. then .. else"
statement: (test) ? this : or_that; 

Here's what I have:

use strict;
use warnings;

my $weight = 40.18;

my $half_kilos = (( int($weight) -30 ) * 2);
print "$half_kilos\n";
if ( (($weight - 30) - (int($weight) - 30)) != 0 ) {
    ( ($weight - int($weight)) < 0.5 ) ? $half_kilos += 1 : $half_kilos += 2;
    print "$half_kilos\n";
}

I expect $half_kilos to be 21. Failing that, 22. But I get 23!

There's probably something really simple here I've not spotted, can 
someone please enlighten me? I admit that my example would be clearer
written as a regular 'if...then...else', but I'd only just remembered
these and had used one (in a simpler form), and wanted to drum it in, so
used it again... I can remember how they work now... but can't get this
one to work.

Thank you for any help you can give.


	Justin.

-- 
Justin C, by the sea.


------------------------------

Date: Tue, 21 Jul 2009 10:13:34 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: if .. then .. else shorthand problem
Message-Id: <4a65db1f$0$48215$815e3792@news.qwest.net>

Justin C wrote:
> I've only just started using the shorthand for the "if .. then .. else"
> statement: (test) ? this : or_that; 
> 
> Here's what I have:
> 
> use strict;
> use warnings;
> 
> my $weight = 40.18;
> 
> my $half_kilos = (( int($weight) -30 ) * 2);
> print "$half_kilos\n";
> if ( (($weight - 30) - (int($weight) - 30)) != 0 ) {
>     ( ($weight - int($weight)) < 0.5 ) ? $half_kilos += 1 : $half_kilos += 2;
>     print "$half_kilos\n";
> }
> 
> I expect $half_kilos to be 21. Failing that, 22. But I get 23!
> 
> There's probably something really simple here I've not spotted, can 
> someone please enlighten me? I admit that my example would be clearer
> written as a regular 'if...then...else', but I'd only just remembered
> these and had used one (in a simpler form), and wanted to drum it in, so
> used it again... I can remember how they work now... but can't get this
> one to work.
> 
> Thank you for any help you can give.

Maybe this will show the issue more clearly.
my $weight = 40.18;

my $half_kilos = (( int($weight) -30 ) * 2);
print "$half_kilos\n";
if ( (($weight - 30) - (int($weight) - 30)) != 0 ) {
     ( ($weight - int($weight)) < 0.5 )
	? $half_kilos .= 'a'
	: $half_kilos .= 'b';
     print "$half_kilos\n";
}
20
20ab


Solutions:

    $half_kilos += ( ($weight - int($weight)) < 0.5 ) ? 1 : 2;

or

    ( ($weight - int($weight)) < 0.5 )
	? ( $half_kilos += 1 )
	: ( $half_kilos += 2 );
	
	


------------------------------

Date: Tue, 21 Jul 2009 21:20:21 +0100
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: if .. then .. else shorthand problem
Message-Id: <Hamdna5fk6iYvvvXnZ2dnUVZ8h-dnZ2d@pipex.net>

J. Gleixner wrote:
> 
> Maybe this will show the issue more clearly.

But it doesn't show what the problem was, whereas looking at the perlop 
page does:

=====
   Because this operator produces an assignable result, using assignments
   without parentheses will get you in trouble.  For example, this:

       $a % 2 ? $a += 10 : $a += 2

   Really means this:

       (($a % 2) ? ($a += 10) : $a) += 2

   Rather than this:

       ($a % 2) ? ($a += 10) : ($a += 2)

   That should probably be written more simply as:

       $a += ($a % 2) ? 10 : 2;

=====

    and "$half_kilos .= 'a'" is an assignment.

-- 
              Just because I've written it doesn't mean that
                   either you or I have to believe it.


------------------------------

Date: Tue, 21 Jul 2009 17:54:09 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: if .. then .. else shorthand problem
Message-Id: <87eis9przi.fsf@yahoo.com>

>> On Tue, 21 Jul 2009 14:21:26 -0000,
>> Justin C <justin.0903@purestblue.com> said:

> I've only just started using the shorthand for the "if
> .. then .. else" statement: (test) ? this : or_that;

> ( ($weight - int($weight)) < 0.5 ) ?
> $half_kilos += 1 : $half_kilos += 2;

Ew :-)

Another post indicated the parsing pitfall of putting
assignment in the ?: operator sequence.  Better to keep ?:
limited to just evaluation as "perldoc perlop" suggests.

hth
t



------------------------------

Date: Tue, 21 Jul 2009 22:05:58 +0000 (UTC)
From: Rahul <nospam@nospam.invalid>
Subject: should I force a install for DBD::mysql if tests fail?
Message-Id: <Xns9C4FACD59A3CE6650A1FC0D7811DDBC81@188.40.43.213>

I tried to install from CPAN "DBD::mysql" and it failed saying:

Running make install
  make test had returned bad status, won't install without force

I can see that the tests are failing like so:

       all skipped: ERROR: Access denied for user 'root'@'localhost' (using 
password: NO). Can't continue test
t/40keyinfo.................skipped

etc.


It seems that mysql is not allowing it to connect passwordless as root. 
This seems desirable to me! Should I just force the install somehow or is 
there a cleaner fix?

-- 
Rahul


------------------------------

Date: Tue, 21 Jul 2009 15:08:03 -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: <3rqhj6xkfj.ln2@goaway.wombat.san-francisco.ca.us>

On 2009-07-21, Rahul <nospam@nospam.invalid> wrote:
> I tried to install from CPAN "DBD::mysql" and it failed saying:
>
> Running make install
>   make test had returned bad status, won't install without force
>
> I can see that the tests are failing like so:
>
>        all skipped: ERROR: Access denied for user 'root'@'localhost' (using 
> password: NO). Can't continue test
> t/40keyinfo.................skipped
>
> It seems that mysql is not allowing it to connect passwordless as root. 
> This seems desirable to me! Should I just force the install somehow or is 
> there a cleaner fix?

You can build the module manually, specifying a userid/password
combination to perl Makefile.PL.  Do

perl Makefile.PL --help

to see the options you can pass.  (I don't know if there is a way to
pass these parameters though from within CPAN; it'd be nice if there
were.)

Do you need the latest version for a specific reason?  If not, and you
are on a linux platform, your distro probably already provides DBD::mysql
in one of its packages.

--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: Tue, 21 Jul 2009 22:39:47 +0000 (UTC)
From: Rahul <nospam@nospam.invalid>
Subject: Re: should I force a install for DBD::mysql if tests fail?
Message-Id: <Xns9C4FB290FCFA16650A1FC0D7811DDBC81@188.40.43.213>

Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us> wrote in 
news:3rqhj6xkfj.ln2@goaway.wombat.san-francisco.ca.us:

> Do you need the latest version for a specific reason?  If not, and you
> are on a linux platform, your distro probably already provides DBD::mysql
> in one of its packages.
> 

Thanks Keith! I was installing Bugzilla and its pre-installation check-
script "checksetup.pl" complained:

* In order to access your database, Bugzilla requires that the        *
* correct "DBD" module be installed for the database that you are     *
* running. 
MySQL: /usr/bin/perl install-module.pl DBD::mysql
            Minimum version required: 4.00

I am on RHEL. I tried "yum info perl-DBD-mysql" and it says:

[snip]
Version    : 3.0007
Release    : 2.el5
Size       : 326 k
Repo       : installed
[snip]

So I assume the native version won't do! Is there any other way out? What 
would you recommend in this case?


-- 
Rahul


------------------------------

Date: Tue, 21 Jul 2009 15:53:22 -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: <2gthj6xe3k.ln2@goaway.wombat.san-francisco.ca.us>

On 2009-07-21, Rahul <nospam@nospam.invalid> wrote:
> Thanks Keith! I was installing Bugzilla and its pre-installation check-
> script "checksetup.pl" complained:
>
> * In order to access your database, Bugzilla requires that the        *
> * correct "DBD" module be installed for the database that you are     *
> * running. 
> MySQL: /usr/bin/perl install-module.pl DBD::mysql
>             Minimum version required: 4.00

Okay, so clearly you need a newer version.

> I am on RHEL.

There are many versions of RHEL; I'm guessing you're on 5, but if not
you should specify.

> I tried "yum info perl-DBD-mysql" and it says:
>
> [snip]
> Version    : 3.0007
> Release    : 2.el5
> Size       : 326 k
> Repo       : installed
> [snip]
>
> So I assume the native version won't do! Is there any other way out? What 
> would you recommend in this case?

You have at least three options, of which I slightly prefer the first.

First is to do what I suggested in my earlier post, though there may be
a somewhat cleaner way.  From CPAN, do

get DBD::mysql
look DBD::mysql

Then run perl Makefile.PL with the extra options you need.  (You should
ideally provide a database, and a user/password combination which can
write to that database.)  When done, do

exit # exits the subshell
test DBD::mysql

These should now pass if your user has enough privileges.

Second is to simply force CPAN to install even though the tests failed.
From CPAN do

force install DBD::mysql

You may get into trouble if the build failed, however.

Third is to use rpmforge to install a v4 version of DBD::mysql.  This
may have far-reaching repercussions on your RHEL updates, so you should
read the docs carefully before going this route.  (If you have rpmforge
questions you should probably ask in a different newsgroup.)

-- 
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: Tue, 21 Jul 2009 23:14:42 +0000 (UTC)
From: Rahul <nospam@nospam.invalid>
Subject: Re: should I force a install for DBD::mysql if tests fail?
Message-Id: <Xns9C4FB87CC35B96650A1FC0D7811DDBC81@188.40.43.213>

Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us> wrote in 
news:2gthj6xe3k.ln2@goaway.wombat.san-francisco.ca.us:

> There are many versions of RHEL; I'm guessing you're on 5, but if not
> you should specify.

Right, my bad! Didn't realize it could be relevant.

Red Hat Enterprise Linux Server release 5.3 (Tikanga)

-- 
Rahul


------------------------------

Date: Tue, 21 Jul 2009 23:40:31 +0000 (UTC)
From: Rahul <nospam@nospam.invalid>
Subject: Re: should I force a install for DBD::mysql if tests fail?
Message-Id: <Xns9C4FBCDD8C9966650A1FC0D7811DDBC81@188.40.43.213>

Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us> wrote in 
news:2gthj6xe3k.ln2@goaway.wombat.san-francisco.ca.us:

> You have at least three options, of which I slightly prefer the first.
> 

Thanks Keith. I got it installed now. Motivated by comments it did it using 
a slightly modified "Option 4"

mysql>grant all privileges on test.* to 'root'@'localhost' identified by ''

perl -MCPAN -e 'install   DBD::mysql'

mysql> ####commands to revoke passwordless loging####

-- 
Rahul


------------------------------

Date: Tue, 21 Jul 2009 10:15:15 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: SpreadSHeet::WriteExcel Error
Message-Id: <766290cb-64a3-4015-9bc6-756f2e276a3c@d4g2000prc.googlegroups.com>

On Jul 21, 3:07=A0am, Rajpreet <rajpreetsi...@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?
>
> Sample Code:
> #!/tools/perl/bin/perl
> use Spreadsheet::WriteExcel;

  # well-written programs always include lines below

  use strict;
  use warnings;


>
> my $logFile;
> $logFile =3D"/users/rajpreet/Perl_Test07012009.xls";
> #unlink($logFile);
> print ("logfile is $logFile \n");
> $workbook
=A0 =A0 =A0 =A0 =A0 =3D Spreadsheet::WriteExcel->new('$logFile');
                                         ^^^^^^^^^^^
                                         ^^^^^^^^^^^

 perldoc perlintro for an explanation of what's
 wrong with your quote selection above.

> print "At the end of file \n";
>
> Error:
> Can't open $logFile. It may be in use or protected at /auto/rajpreet/
> test.pl line 8
> logfile is /rajpreet/Perl_Test07012009.xls
> At the end of file
>




------------------------------

Date: Tue, 21 Jul 2009 11:44:45 -0400
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Which distro for windows?
Message-Id: <1fob651fslf4o3qvim69sibij7of74976q@216.168.3.66>

On one system I have Activestate Perl and on another I have Strawberry
perl.  both seem OK, although the Activestate one seems a bit "slicker"
[OTOH, Strawberry perl includes enough machinery to install stuff from
CPN.. I *think* that with Activestate you can only install prebuilt stuff
from repositories].  I'm setting up a new computer and I'm torn about which
to install...  any thoughts/advice?  tnx!

  /Bernie\
-- 
Bernie Cosell                     Fantasy Farm Fibers
bernie@fantasyfarm.com            Pearisburg, VA
    -->  Too many people, too few sheep  <--          


------------------------------

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 2525
***************************************


home help back first fref pref prev next nref lref last post