[27392] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9064 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 18 14:05:37 2006

Date: Sat, 18 Mar 2006 11:05:06 -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           Sat, 18 Mar 2006     Volume: 10 Number: 9064

Today's topics:
    Re: A Problem With GD <markem@airmail.net>
    Re: A Problem With GD <jurgenex@hotmail.com>
    Re: Code that makes you say hmmm! <zentara@highstream.net>
    Re: Code that makes you say hmmm! <matthew.garrish@sympatico.ca>
    Re: Code that makes you say hmmm! <1usa@llenroc.ude.invalid>
        XML::Simple and utf8 woes <corff@zedat.fu-berlin.de>
    Re: XML::Simple and utf8 woes <ngoc@yahoo.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 18 Mar 2006 09:00:58 -0600
From: Mark Manning <markem@airmail.net>
Subject: Re: A Problem With GD
Message-Id: <121o831h4u70if9@corp.supernews.com>

Abigail wrote:
> ==  Well that's strange.  I thought one of the strong points of Perl was that it
> ==  guaranteed to always do the pre-increment command before doing anything else
> 
> 
> It doesn't. And this fact is documented. 

I'm sorry, but - I just did a search using Google to find where this is 
documented and looked through all of my Perl books.  I can not find where this 
is documented.  Do you have a website where I may read up on this?

> ==  Unlike C/C++ where you are not guaranteed to be able to do this.
> 
> Pre/post increment/decrement works "as in C". With the same benefits.
> And the same flexibility for the implementation.

Well, I know Perl works a lot like C/C++ but if I remember correctly, Mr. Wall 
stated a number of years ago that since Perl was in interpreter instead of a 
compiler that the interpreter he had written (which may now be in Lex & Yacc for 
all I know and I do recall that Perl 5 had many changes to it) corrected the 
problem the compilers introduced by ensuring that pre-incremented variables 
would always be pre-incremented before the rest of the equation was evalutated.
> 
> ==  Would you say that "$v = (++$v) % 2" would always work due to the parenthesi
> 
> That still modifies $v twice in the same expression.
> 
> ==  Or just in general the ++$v may not work?
> 
> In general '++ $v' works. Just don't modify the same thing twice in 
> the same expression.
> 
> 
> Abigail

This would never work for me.  Some of my 3D graphics routines require dual 
manipulation of variables to create an undefined state.  :-)

Still, would you consider: $a = &funca($a) + &funcb($a)
bad if both funca and funcb modified $a?



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

Date: Sat, 18 Mar 2006 15:44:48 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: A Problem With GD
Message-Id: <QVVSf.9847$bu.793@trnddc04>

Mark Manning wrote:
> Still, would you consider: $a = &funca($a) + &funcb($a)
> bad if both funca and funcb modified $a?

Absolutely. Other bad styles (like Perl4 function calls) set aside, if funca 
and funcb modify their parameter then I would even consider
    $foo = funca($a) + funcb($a)
very bad style because + is commutative.

Therefore I would never rely on funca being called before funcb, even if the 
programming language would define the execution order explicitely. It is 
just too human to make some mistakes somewhere down the line when just 
swapping two arguments of an addition.

jue




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

Date: Sat, 18 Mar 2006 14:05:20 GMT
From: zentara <zentara@highstream.net>
Subject: Re: Code that makes you say hmmm!
Message-Id: <dj4o121gm2l64sndkpm1m8277cadcnib5s@4ax.com>

On Sat, 18 Mar 2006 11:21:32 GMT, "John W. Krahn" <someone@example.com>
wrote:

>I downloaded a Perl program recently and encountered this line:
>
>    if(exists $_[0]->{"name"} and scalar($_[0]->{"name"}) eq $_[0]->{"name"}){

>Comments?  Jokes?
>John

Rumpelstiltskin?


-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


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

Date: Sat, 18 Mar 2006 10:14:02 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Code that makes you say hmmm!
Message-Id: <ZsVSf.7667$fy1.338822@news20.bellglobal.com>


"John W. Krahn" <someone@example.com> wrote in message 
news:03SSf.2749$nQ6.1906@clgrps13...
>I downloaded a Perl program recently and encountered this line:
>
>
>    if(exists $_[0]->{"name"} and scalar($_[0]->{"name"}) eq 
> $_[0]->{"name"}){
>
>
> Comments?  Jokes?
>

You're forgetting your Monty Python. Anyone can get past the "what is your 
name" question. It's the favourite colour that'll get you in the end... : )

Matt 




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

Date: Sat, 18 Mar 2006 17:04:33 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Code that makes you say hmmm!
Message-Id: <Xns978A7AF51CE2Fasu1cornelledu@127.0.0.1>

"John W. Krahn" <someone@example.com> wrote in
news:03SSf.2749$nQ6.1906@clgrps13: 

> I downloaded a Perl program recently and encountered this line:
> 
> 
>     if(exists $_[0]->{"name"} and scalar($_[0]->{"name"}) eq
>     $_[0]->{"name"}){ 

Maybe we need a 

alt.perl-maintainer.recovery

newsgroup.

Sinan
 
-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



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

Date: 18 Mar 2006 14:07:13 GMT
From: <corff@zedat.fu-berlin.de>
Subject: XML::Simple and utf8 woes
Message-Id: <482ighFi5utaU1@uni-berlin.de>

Dear wizards,

I use XML::Simple to parse an XML file and
also to write it out. The problem lies in the
utf8 character data contained in the XML
source. While the XMLin() function seems
to read them properly, the XMLout() function
tries to replace utf8 material by multibyte
nonsense.

Below is my minimal example, run under perl 5.8.5
on a Fedora C3 box. Just compare the output
of the script (in w.xml) with its input, in DATA.

Please advice on how to fix the broken utf8 output.

Thanks in advance,
Oliver.

#!/usr/bin/perl
use XML::Simple;
print "Reading data from XML source...\n";
$data=XMLin(\*DATA,
	ForceArray=>[manju,hauer],
	ContentKey=>'-content',
	KeyAttr=>[name],
);
print "Retrieve and display data example:\n";
$k='0004.1';
print $k.": ".
	$data->{lemma}->{$k}->{manju}->[0].
	"\n";
print "Writing data to XML file...\n";
XMLout($data,
	NumericEscape=>0,
	RootName=>'wuti',
	XMLDecl=>1,
	OutputFile=>'w.xml',
);
__DATA__
<?xml version='1.0' encoding='utf-8' standalone='yes'?>
<wuti>
  <lemma name="0004.1">
    <hauer>in der Morgendämmerung (H).</hauer>
    <manju>farhûn suwaliyame</manju>
  </lemma>
  <lemma name="0004.2">
    <hauer>Morgendämmerung.</hauer>
    <manju>gersi fersi</manju>
  </lemma>
</wuti>

-- 
Dr. Oliver Corff              e-mail:    corff@zedat.fu-berlin.de


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

Date: Sat, 18 Mar 2006 17:38:11 +0100
From: ngoc <ngoc@yahoo.com>
Subject: Re: XML::Simple and utf8 woes
Message-Id: <0cKdnfpsqeT-qoHZRVnzvA@telenor.com>


> Below is my minimal example, run under perl 5.8.5
> on a Fedora C3 box. Just compare the output
> of the script (in w.xml) with its input, in DATA.
I tried your code in Windows XP. It gives utf-8 output. But if I use 
RootName => 'unicode here', only the output of rootname is changed 
(manual fix will help), other parts are in utf-8. I suggest you

1. To save your perl program in utf-8 encoding.

2. This step in theory is not necessary. But maybe it helps

open my $fh, '>:encoding(UTF-8)', $path or die "open($path): $!";
   XMLout($ref, OutputFile => $fh);

3. Try in Windows XP or 2000 environment to see it is different


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

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


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