[27766] in Perl-Users-Digest
Perl-Users Digest, Issue: 9140 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 10 14:05:54 2006
Date: Mon, 10 Apr 2006 11:05:05 -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 Mon, 10 Apr 2006 Volume: 10 Number: 9140
Today's topics:
Re: A problem with precedence <ced@blv-sam-01.ca.boeing.com>
Re: A problem with precedence xhoster@gmail.com
EXAMPLE -- Re: Strange issue with `CHOMP' not working.. <ignoramus20015@NOSPAM.20015.invalid>
Re: FAQ 3.22 How can I compile Perl into Java? <brian.d.foy@gmail.com>
Re: Problem using Openoffice::OODoc <daveandniki@ntlworld.com>
Strange issue with `CHOMP' not working... <ignoramus20015@NOSPAM.20015.invalid>
Re: Strange issue with `CHOMP' not working... <prawnMUNG@prawn.me.uk>
Re: Strange issue with `CHOMP' not working... xhoster@gmail.com
Re: Strange issue with `CHOMP' not working... <ignoramus20015@NOSPAM.20015.invalid>
Re: Strange issue with `CHOMP' not working... <ignoramus20015@NOSPAM.20015.invalid>
Re: utf8 filenames <hjp-usenet2@hjp.at>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 10 Apr 2006 15:27:44 GMT
From: Charles DeRykus <ced@blv-sam-01.ca.boeing.com>
Subject: Re: A problem with precedence
Message-Id: <IxIIy9.7wC@news.boeing.com>
Abigail wrote:
> Lukas Mai (rwxr-xr-x@gmx.de) wrote on MMMMDCIV September MCMXCIII in
> <URL:news:e1b1nt$98g$00$1@news.t-online.com>:
> <> Mark Hobley <markhobley@hotpop.deletethisbit.com> schrob:
> <>
> <> > I now add brackets to change the precedence:
> <> >
> <> > print (4 + 2) * 3; # This unexpectedly gives 6
> <>
> <> Use warnings.
>
> Actually, the fact this gives a warning is a damn good reason to NOT
> use warnings.
>
> Because Perl is more often wrong about this warning than it is right.
> If I were to advocate against using Perl, I'd point out the warnings
> it gives with 'print', and then rest my case.
>
> print(4 + 2) * 3; # No warning.
> print (4 + 2) * 3; # Warning.
> print (4 + 2) * 3; # No warning (!)
> print (4 + 2) * 3; # No warning.
>
> Four mistakes, only one warning.
I agree but the void context warnings returned are generally useful:
$ perl -wle 'print(4 + 2) * 3;' # (print(6) * 3);
Useless use of multiplication (*) in void context at -e line 1.
$ perl -wle 'print(4 + 2) * 3;'
Useless use of multiplication (*) in void context at -e line 1.
6
$ perl -wle 'print (4 + 2) * 3; '
Useless use of multiplication (*) in void context at -e line 1.
6
$ perl -wle 'print (4 + 2) * 3;'
print (...) interpreted as function at -e line 1.
Useless use of multiplication (*) in void context at -e line 1.
6
$ perl -wle 'print (4 + 2) * 3;'
Useless use of multiplication (*) in void context at -e line 1.
> But it gets better.
>
> print (4 + 2) * 3; # Warning.
> printf (4 + 2) * 3; # Warning.
> sprintf (4 + 2) * 3; # No warning.
5.8.7 does warn here though since the expression gets optimized away:
$ perl -wle 'sprintf (4 + 2) * 3;'
Useless use of a constant in void context at -e line 1.
> sort (4 + 2) * 3; # Warning.
$ perl -wle 'sort (4 + 2) * 3;'
sort (...) interpreted as function at -e line 1.
Useless use of sort in scalar context at -e line 1.
Useless use of multiplication (*) in void context at -e line 1.
Use of uninitialized value in multiplication (*) at -e line 1.
> sin (4 + 2) * 3; # No warning.
$ perl -wle 'sin (4 + 2) * 3;'
Useless use of a constant in void context at -e line 1.
>....
--
Charles DeRykus
------------------------------
Date: 10 Apr 2006 15:50:16 GMT
From: xhoster@gmail.com
Subject: Re: A problem with precedence
Message-Id: <20060410120148.667$eg@newsreader.com>
Abigail <abigail@abigail.nl> wrote:
> Lukas Mai (rwxr-xr-x@gmx.de) wrote on MMMMDCIV September MCMXCIII in
> <URL:news:e1b1nt$98g$00$1@news.t-online.com>:
> <> Mark Hobley <markhobley@hotpop.deletethisbit.com> schrob:
> <>
> <> > I now add brackets to change the precedence:
> <> >
> <> > print (4 + 2) * 3; # This unexpectedly gives 6
> <>
> <> Use warnings.
>
> Actually, the fact this gives a warning is a damn good reason to NOT
> use warnings.
>
> Because Perl is more often wrong about this warning than it is right.
That is not my experience.
> If I were to advocate against using Perl, I'd point out the warnings
> it gives with 'print', and then rest my case.
>
> print(4 + 2) * 3; # No warning.
> print (4 + 2) * 3; # Warning.
> print (4 + 2) * 3; # No warning (!)
> print (4 + 2) * 3; # No warning.
>
> Four mistakes, only one warning.
Strange, I get 6 warning.
print (...) interpreted as function at foo line 2.
print (...) interpreted as function at foo line 3.
Useless use of multiplication (*) in void context at foo line 1.
Useless use of multiplication (*) in void context at foo line 2.
Useless use of multiplication (*) in void context at foo line 3.
Useless use of multiplication (*) in void context at foo line 4.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Mon, 10 Apr 2006 17:56:27 GMT
From: Ignoramus20015 <ignoramus20015@NOSPAM.20015.invalid>
Subject: EXAMPLE -- Re: Strange issue with `CHOMP' not working...
Message-Id: <f%w_f.134881$u%1.132371@fe42.usenetserver.com>
OK, here's an example to illustrate my problem with chomp.
To those who have not seen my original post, please see it first.
The file I read has not changed in years. When I read it,I get
INTERMITTENT errors with chomp, they do not happen every time.
This is a real life perl module that fails.
The messages that I see in my errors file are something like this:
Algebra::Config: BAD BAD BAD Input string after chomp but BEFORE regex: 'show_counter=yes
Things look even worse than that, actually, as it seems that sometimes
requesting a single line from a file slurps the entire file. Another
tip, these issues pop up only a few minutes after the webserver is
restarted.
Look for BAD BAD BAD print in the file to see where I print the error
message.
======================================================================
package Algebra::Config;
use strict;
require Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ISA = qw(Exporter);
@EXPORT= qw( get_config_var get_data_dir get_algebra_root );
@EXPORT_OK = qw( get_config_var );
$VERSION = 2000.0426;
use vars qw( $algebra_data_dir );
sub get_algebra_root {
my $algebra_root = $ENV{'ALGEBRA_ROOT'} || $ENV{'DOCUMENT_ROOT'}
|| die "Webmaster has to define ALGEBRA_ROOT environment variable!";
return $algebra_root;
}
sub get_config_var {
my ($category, $variable) = @_;
my $algebra_root = get_algebra_root;
my $config_file = "$algebra_root/etc/$category";
die "Config file '$config_file' does not exist or is not readable."
unless -r $config_file;
open( CONFIG, $config_file );
while( $_ = <CONFIG> ) {
chomp;
if( /(\n|\r)/ ) {
print STDERR "Algebra::Config: BAD BAD BAD Input string after chomp but BEFORE regex: '$_'.\n";
}
$_ =~ s/(\n|\r)//;
next if( /^\s*#/ );
next if( /^\s*$/ );
my( $key, $value ) = split( /\s*=\s*/, $_ );
return $value if( $key eq $variable );
}
return undef;
}
$algebra_data_dir = get_config_var( "general", "algebra_data_dir" )
|| $ENV{'ALGEBRA_ROOT'};
sub get_data_dir {
my ($category, $variable) = @_;
my $dir = get_config_var( $category, $variable );
if( !($dir =~ /^\// ) ) {
$dir = $algebra_data_dir . "/$dir";
}
return $dir;
}
1;
------------------------------
Date: Mon, 10 Apr 2006 09:50:08 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 3.22 How can I compile Perl into Java?
Message-Id: <100420060950085233%brian.d.foy@gmail.com>
In article <49unuhFqeal6U1@news.dfncis.de>, Anno Siegel
<anno4000@lublin.zrz.tu-berlin.de> wrote:
> Matt Garrish <matthew.garrish@sympatico.ca> wrote in comp.lang.perl.misc:
> > > 3.22: How can I compile Perl into Java?
> > >
> > > You can also integrate Java and Perl with the Perl Resource Kit from
> > > O'Reilly Media. See http://www.oreilly.com/catalog/prkunix/ .
> > A case of bad grammar, or is part of this FAQ missing?
[Note: Matt's message didn't make it through to me, so I boggled a bit
over what he was referring to. It helps me if people explicitly point
out the part they are talking about, perhaps like "Is 'You can also'
just bad grammar", and so on. :) ]
> It ("also") makes more sense in context with the previous question
> "How can I compile my Perl program into byte code or C?", but I'd
> take it out.
I'll fix up the answer. Thanks :)
*** Free account sponsored by SecureIX.com ***
*** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.com ***
------------------------------
Date: Mon, 10 Apr 2006 16:10:44 +0200
From: "Dave" <daveandniki@ntlworld.com>
Subject: Re: Problem using Openoffice::OODoc
Message-Id: <443a676a$0$21259$8fcfb975@news.wanadoo.fr>
"Christian Winter" <thepoet_nospam@arcor.de> wrote in message
news:443a4d26$0$11062$9b4e6d93@newsread4.arcor-online.net...
> Dave schrieb:
>> In the following test script I am expecting the second sentence in
>> paragraph 2 to be in the Emphasis style (italicised), but it remains in
>> the default style. Does anyone know why? I think that I am following the
>> documentation correctly. (Perl 5.8.7, Openoffice::OODoc 2.02 on Windows
>> XP with OpenOffice 2.0).
>>
>> use strict;
>> use warnings;
>> use OpenOffice::OODoc;
>>
>> my $document = ooDocument(file => 'test.odt', create => 'text');
>>
>> my $para1 = $document->appendParagraph( text => 'Heading',
>> style => 'Heading 1'
>> );
>>
>> my $para2 = $document->appendParagraph( text => 'First sentence para2.
>> ',
>> style => 'default'
>> );
>>
>> my $para3 = $document->appendParagraph( text => 'First sentence para3.
>> ',
>> style => 'default'
>> );
>>
>> $document->extendText($para2, 'Second sentence para2.', 'Emphasis');
>>
>> $document->save;
>
> It seems that either the behaviour of the extendText method has changed
> with Version 2.222 or the documentation is inconsistent (I'll asume the
> first). While the 2.222 documentation on CPAN lists an
> extendText(element,style) method, my local installation (Version 2.219)
> only has the following two:
> extendText(path, position, text)
> extendText(element, text)
> so I guess that it silently discards the third parameter.
>
> To assign a different style to a subset of a paragraph you can use the
> setSpan() method:
>
> $document->extendText($para2, ' Second sentence para2.' );
> $document->setSpan( $para2, 'Second.*para2.', 'Emphasis' );
>
> HTH
> -Chris
Thanks. Yes I got version 2.021 from ppm, but I had been reading the lastest
version of the docs from CPAN. I updated Text.pm and XPath.pm by copying the
files from CPAN and it now works.
------------------------------
Date: Mon, 10 Apr 2006 15:48:23 GMT
From: Ignoramus20015 <ignoramus20015@NOSPAM.20015.invalid>
Subject: Strange issue with `CHOMP' not working...
Message-Id: <b7v_f.82416$o25.16095@fe48.usenetserver.com>
I have a mod_perl based website algebra.com. In a few places, it does
'chomp' when it reads various files.
It all worked fine for years and I had not touched any code lately,
especially nothing related to chomp.
In the last week or so, it broke for some reasons and chomp no longer
chomps lines, in at least a couple of pieces of code that I did not
touch.
As a result, my site did not work properly.
I suspect that perhaps I upgraded some perl modules such as
SpamAssassin, and possibly somehow that could have messed up the
behavior of chomp.
Any ideas as to why this is happening.
i
------------------------------
Date: Mon, 10 Apr 2006 16:57:14 +0100
From: prawn <prawnMUNG@prawn.me.uk>
Subject: Re: Strange issue with `CHOMP' not working...
Message-Id: <443a805a$0$2539$ed2619ec@ptn-nntp-reader02.plus.net>
Ignoramus20015 wrote:
> I have a mod_perl based website algebra.com. In a few places, it does
> 'chomp' when it reads various files.
>
> It all worked fine for years and I had not touched any code lately,
> especially nothing related to chomp.
>
> In the last week or so, it broke for some reasons and chomp no longer
> chomps lines, in at least a couple of pieces of code that I did not
> touch.
>
> As a result, my site did not work properly.
>
> I suspect that perhaps I upgraded some perl modules such as
> SpamAssassin, and possibly somehow that could have messed up the
> behavior of chomp.
>
> Any ideas as to why this is happening.
>
> i
>
Without any data, I can't say. I had the same issue today processing a
dos file on a unix box and:
my $s =~ s/\r\n$//; [1]
did the trick.
[1] It /think/ that it was that way round :-)
--
p LotR#9 BotM#1
------------------------------
Date: 10 Apr 2006 16:09:23 GMT
From: xhoster@gmail.com
Subject: Re: Strange issue with `CHOMP' not working...
Message-Id: <20060410122055.093$hh@newsreader.com>
Ignoramus20015 <ignoramus20015@NOSPAM.20015.invalid> wrote:
> I have a mod_perl based website algebra.com. In a few places, it does
> 'chomp' when it reads various files.
>
> It all worked fine for years and I had not touched any code lately,
> especially nothing related to chomp.
>
> In the last week or so, it broke for some reasons and chomp no longer
> chomps lines, in at least a couple of pieces of code that I did not
> touch.
>
> As a result, my site did not work properly.
>
> I suspect that perhaps I upgraded some perl modules such as
> SpamAssassin, and possibly somehow that could have messed up the
> behavior of chomp.
>
> Any ideas as to why this is happening.
Maybe something related to binmode/utf.
Maybe people are starting to
use your website from non-IE browser and that causes problems because
different browsers use different eol.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Mon, 10 Apr 2006 16:35:51 GMT
From: Ignoramus20015 <ignoramus20015@NOSPAM.20015.invalid>
Subject: Re: Strange issue with `CHOMP' not working...
Message-Id: <HPv_f.13997$oh1.9131@fe24.usenetserver.com>
On Mon, 10 Apr 2006 16:57:14 +0100, prawn <prawnMUNG@prawn.me.uk> wrote:
> Ignoramus20015 wrote:
>> I have a mod_perl based website algebra.com. In a few places, it does
>> 'chomp' when it reads various files.
>>
>> It all worked fine for years and I had not touched any code lately,
>> especially nothing related to chomp.
>>
>> In the last week or so, it broke for some reasons and chomp no longer
>> chomps lines, in at least a couple of pieces of code that I did not
>> touch.
>>
>> As a result, my site did not work properly.
>>
>> I suspect that perhaps I upgraded some perl modules such as
>> SpamAssassin, and possibly somehow that could have messed up the
>> behavior of chomp.
>>
>> Any ideas as to why this is happening.
>>
>> i
>>
>
> Without any data, I can't say. I had the same issue today processing a
> dos file on a unix box and:
>
> my $s =~ s/\r\n$//; [1]
>
> did the trick.
>
> [1] It /think/ that it was that way round :-)
>
I had to do the same thing as well, to replace a regexp. But I an
miffed and worried that other places where chomp is used, would not
work as well.
i
------------------------------
Date: Mon, 10 Apr 2006 16:36:39 GMT
From: Ignoramus20015 <ignoramus20015@NOSPAM.20015.invalid>
Subject: Re: Strange issue with `CHOMP' not working...
Message-Id: <rQv_f.13998$oh1.11846@fe24.usenetserver.com>
On 10 Apr 2006 16:09:23 GMT, xhoster@gmail.com <xhoster@gmail.com> wrote:
> Ignoramus20015 <ignoramus20015@NOSPAM.20015.invalid> wrote:
>> I have a mod_perl based website algebra.com. In a few places, it does
>> 'chomp' when it reads various files.
>>
>> It all worked fine for years and I had not touched any code lately,
>> especially nothing related to chomp.
>>
>> In the last week or so, it broke for some reasons and chomp no longer
>> chomps lines, in at least a couple of pieces of code that I did not
>> touch.
>>
>> As a result, my site did not work properly.
>>
>> I suspect that perhaps I upgraded some perl modules such as
>> SpamAssassin, and possibly somehow that could have messed up the
>> behavior of chomp.
>>
>> Any ideas as to why this is happening.
>
> Maybe something related to binmode/utf.
>
> Maybe people are starting to
> use your website from non-IE browser and that causes problems because
> different browsers use different eol.
Well, the problems are with reading config files on my local disk, not
user submitted data. I just checked dates on some of them, they are
quite old and have not changed.
i
------------------------------
Date: Mon, 10 Apr 2006 17:42:02 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: utf8 filenames
Message-Id: <1594451.sJFOnGn05h@bernon.wsr.ac.at>
Christopher Key wrote:
> I'm trying to understand the correct way to handle the following. Say I
> have a file containing non ascii characters, e.g. as 8 bit values 66 69 6C
> E9, or 'f' 'i' 'l' 'e_acute', and I want to establish whether that file
> exists.
>
> If I execute:
>
> ex("c:\\fil\x{e9}.txt");
> ex("c:\\fil" . pack("U", 0xe9 ) . ".txt");
>
> sub ex {
> my $f = shift;
> print $f;
> print ((-e $f) ? " exists" : " doesn't exist");
> print "\n";
> }
>
> Then I get the following:
>
> c:\filé.txt exists
> c:\filé.txt doesn't exist
>
> The filename is displayed in exactly the same format to the screen in both
> cases, but it isn't found when the filename is passed as a utf8 string.
> Is there any way to tell perl that the operand being passed to -e is utf8?
>
> One workaround would be to simply convert everything from utf8 to an
> single byte representation, but I've no idea whether this will work in
> environments
> other than mine (Win32, EN_GB, perl v5.8.8). It's also not going to
> handle unicode characters that won't fit into a single byte either.
>
> What is the correct way to handle this to ensure portability?
I think there is currently no way to ensure portability. The string has to
be passed in a format understood by the file system, and there seems to be
no portable way to figure out which format the file system understands.
On Linux, the best way seems to be to inspect the LANG environment variable
and explicitely encode/decode the filenames with the charset. On MacOS X,
that will probably work, too, but I've read that they always use UTF-8.
On Windows, I have no idea. (Windows allows Non-Latin-1 characters in file
names, and I am sure there is some way to access these files in perl)
There was a thread recently about the same topic which sort of tapered off
with no resolution.
Does anybody know if there is some work done in this area on perl 5.9.x?
hp
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 9140
***************************************