[27505] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9091 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 26 06:05:54 2006

Date: Sun, 26 Mar 2006 03:05:05 -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, 26 Mar 2006     Volume: 10 Number: 9091

Today's topics:
    Re: Calculations with ',' as decimal delimiter <bart.lateur@pandora.be>
    Re: is there a way to trigger "reload"? <joe@inwap.com>
    Re: Semi OT: Debugging with Speech, Emacspeak for Win32 <vtatila@mail.student.oulu.fi>
    Re: Semi OT: Debugging with Speech, Smart Spoken Repres <nospam-abuse@ilyaz.org>
    Re: short form for (defined $x and defined $y and ... ) <joe@inwap.com>
    Re: short form for (defined $x and defined $y and ... ) <bart.lateur@pandora.be>
        Source Code release from Vendor <dillon@SpamMinuSaccessdenied.darktech.org>
        Text::Levenshtein and utf8 woes <corff@zedat.fu-berlin.de>
    Re: XML::Simple and utf8 woes <corff@zedat.fu-berlin.de>
    Re: XML::Simple and utf8 woes <hjp-usenet2@hjp.at>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 26 Mar 2006 08:32:08 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Calculations with ',' as decimal delimiter
Message-Id: <38kc229s112js60ajg167ka6f3t1m0b6j8@4ax.com>

Martin Kissner wrote:

>Is it possible to use coma (,) as decimal delimiter for some
>calculations.
>I have a loop and want to get rid of the substitution:
>
>	while($condition) {
>        $value =~ s/,/./;
>        $sum+=$value;
>	}
>
>$value contains values like '1,05', '2,35' and so on.

Why do you want to get rid of the substitution? It's a simple statement
and it takes just a fraction of a microsecond to execute. Any other
solution you can come up with will probably be longer to write down, and
take longer to execute.

Alternatively you can use

	tr/,/./

which replaces all commas in the string.

-- 
	Bart.


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

Date: Sun, 26 Mar 2006 01:52:51 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: is there a way to trigger "reload"?
Message-Id: <zqidnWZVEvrk-bvZRVn-vA@comcast.com>

Manfred Koch wrote:
> I'd like to know if there is a way from client site
> to trigger a "reload".

You're looking in the wrong newsgroup.  That is an HTML question, not perl.
<meta http-equiv="refresh" content="4; url=http://www.inwap.com/"></head>


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

Date: Sun, 26 Mar 2006 11:54:36 +0300
From: "Veli-Pekka Tätilä" <vtatila@mail.student.oulu.fi>
Subject: Re: Semi OT: Debugging with Speech, Emacspeak for Win32
Message-Id: <e05kso$lof$1@news.oulu.fi>

Ilya Zakharevich wrote:
> Alias is just a way to ask debugger to do something by a short command
> line.  E.g., if you have a function foo(L1,L2) which prints some lines
> of code, you can ask PerlDB to call foo(L1, L2) when you give command
>  fo L1 L2
Ah this seems nice. YOur comment about easily accessing code lines is 
useful, too. I dug up the docs, which said:
Quote:
@{"_<$filename"} holds the lines of $filename for a file compiled by Perl.
End quote.

On help text:
> One can easily add new S<> escape, which does nothing in the usual mode, 
> and will break the line at this point if one
> configures PerlDB for a (future) "blind user" mode.
Again thanks for the idea, this would appear to be pretty easy, too. Many 
apps already have some kind of blind user mode built-in. My current text 
editor, NoteTab Pro, for instance, supports autoclosing the find dialog on a 
match in blind-user mode.

Rendering programming languages aurally:
By the way, this is not specific to the debugger but of course the debugger 
Experience would be all the more enjoyable, if some app could do this kind 
of more or less magical filtering.

> I do not think your notes are sufficient <snip>. it knows which,
> e.g., dollar signs are parts of code, of double-quoted strings,
> of comments, of regular expressions <snip>
Yes, you would obviously have to interpret such characters in double quotes 
raw, and interpret regular expressions specially, too. A lot of such things 
are perl specific, however, and my notes at this point are generally about 
c-like languages with some Java and CPP specifics thrown in. I've yet to 
seriously ponder Perl in particular, in this regard. The other reason why I 
didn't separate, say bits in double quotes, is that these are also guide 
lines for the human reader reading bits of code to me on a machine lacking a 
screen reader. Double quotes are easily interpreted right by a human reader, 
but regexp are another matter.

> You have Emacs; you have something like festival (or any other speech
> synthesis program); just write a simple Emacs Lisp function which
> would take a region in Emacs, and will write down what you want to
> a pipe to the speech synthesis program.
Well, there are several issues with this, though I'm willing to try it 
nevertheless. First of all, I'm pretty heavily tied to a Wintel box partly 
because of absolute must-have music, OCR and proprietry reader programs, and 
partly because apart from text editing and programming, I prefer an 
accessible GUI even legally blind, odd as it may seem.

Then I'd need to learn Emacs and Lisp which is not that impossible, I guess. 
I already know some Vi and kind of like it and am considering learning Lisp 
anyway. I sort of like the Lisp syntax in its regularity.

But the last and most serious issue is getting the app itself. Plainly put, 
where can I get a precompiled binary of Emacspeak for Win32 which supports 
Microsoft speech API? I did Googling with different keywords, visited the 
Emacspeaksite and so on but have been unable to find the Windows version. 
I've seen some mails referring to someone's SAPI-enabled port to NT but so 
far it hasn't turned up. Any links would be appreciated.

On a side-note, I would pretty badly need the MS speech API support rather 
than Festival, because this multi-lingual formant speech synth I've been 
using for seven years or so, is a Windows-only, binary release and you 
cannot pipe stuff to it, as far as I know. Switching synths would mean a 
serious productivity decrease because of pronounciation and intelligibility, 
and losing Finnish language support, too, as I've noticed in trying to use 
OS X with the Macintalk voices.

> sure this must have been already done many times.  Google for speech
> in emacs newsgroups...
Will do, thanks for the advice.

-- 
With kind regards Veli-Pekka Tätilä (vtatila@mail.student.oulu.fi)
Accessibility, game music, synthesizers and programming:
http://www.student.oulu.fi/~vtatila/ 




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

Date: Sun, 26 Mar 2006 04:35:08 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Semi OT: Debugging with Speech, Smart Spoken Representation
Message-Id: <e055ls$1dgj$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Veli-Pekka Tätilä
<vtatila@mail.student.oulu.fi>], who wrote in article <e04ifv$bta$1@news.oulu.fi>:
> > instead of navigating the information already on screen via (unflexible)
> > screen-read interface, make PerlDB *repeat* the necessary information by
> > printing something new on screen.
> > This can be easily done by aliases

> Can these aliases span multiple lines or statements?

Alias is just a way to ask debugger to do something by a short command
line.  E.g., if you have a function foo(L1,L2) which prints some lines
of code, you can ask PerlDB to call foo(L1, L2) when you give command

  fo L1 L2

Getting the lines of code is not hard (see perldb guts
documentation).  Maybe there are also some functions exported by
debugger to do this.

> Not that much. The best option would be to have some kind of single column 
> layout with one switch per line. could this splitting to a single column be 
> done using some regexp matching ,that is is the column separator 
> well-defined?

Currently the 'h' text is hard-coded, with only BOLD and ITALIC
escapes.  One can easily add new S<> escape, which does nothing in the
usual mode, and will break the line at this point if one configures
PerlDB for a (future) "blind user" mode.

> Lastly, here are some skeletal notes on how program code could be machine 
> read out loud. They should be simple enough to be expressed in code and most 
> definitely could be followed by a human reader.

> operator prompt
> +        plus
> -        minus

I do not think your notes are sufficient.  Consider a syntax-highlight
editor; then it knows which, e.g., dollar signs are parts of code, of
double-quoted strings, of comments, of regular expressions, of
character classes in regular expressions.  Obviously, they should be
read differently.

Given your interest in this, I do not see why do you need any screen
reader at all.  You have Emacs; you have something like festival (or
any other speech synthesis program); just write a simple Emacs Lisp
function which would take a region in Emacs, and will write down what
you want to a pipe to the speech synthesis program.  Hmm, I'm pretty
sure this must have been already done many times.  Google for speech
in emacs newsgroups...

Or, when you write your aliases for PerlDB, create one with your
transformations in mind (you will not have benefits of syntax
highlighting, though).

Emacs Lisp is something extremely ugly, but already implemented
keyboard navigation + syntax highlighting will compensate for the
problems.

Hope this helps,
Ilya


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

Date: Sun, 26 Mar 2006 01:18:36 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: short form for (defined $x and defined $y and ... )?
Message-Id: <WpqdnV901LjpwbvZRVn-uA@comcast.com>

Markus Dehmann wrote:

> my ($x,$y,$z) = $userInput =~ m/(.+?)\s\+\s(.+?)\s=\s(.+)/;
> die("wrong input format") unless(defined $x and defined $y and defined $z);

Others have shown you the proper way to do it, but I want to point out that
   die "wrong input format" unless defined $z;
would handle it.  If $z is defined, then there is no need to test $x or $y
since they will be defined (even if they are null strings).
	-Joe


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

Date: Sun, 26 Mar 2006 10:55:21 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: short form for (defined $x and defined $y and ... )?
Message-Id: <2nsc22h5llh4t24s593el7fvhltq3h9qpe@4ax.com>

Markus Dehmann wrote:

>I often find myself typing
>
> > unless(defined $x and defined $y and defined $z){ # ... many variables
> >   # ...
> > }
>
>Is there a shorter form to write that? (I mean apart from "&&" for "and").

Invert the condition, and search for an undefined item.

	if(grep !defined, $x, $y, $z) { ... }

-- 
	Bart.


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

Date: Sun, 26 Mar 2006 15:09:02 +0800
From: AcCeSsDeNiEd <dillon@SpamMinuSaccessdenied.darktech.org>
Subject: Source Code release from Vendor
Message-Id: <ndfc22p2haom7qhn3t9f2bnujqp30uq0pj@4ax.com>

Sorry for th OT. But I am unable to find any "specific" ng to post this
question, Being a perly myself, I thought I would just post here.

Was wondering, what is the "normal" practice here is sg when it comes to
releasing the source code by a vendor which you hire to develop a
software for you? If there is no contract in the 1st place and nothing
indicating whether or not the source code would be retained/released by
the vendor?

And if the software was designed in-house with a in-house project
manager? And only the programming labour was outsourced to the vendor in
question.


Thx

To e-mail, remove the obvious


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

Date: 26 Mar 2006 08:45:51 GMT
From: <corff@zedat.fu-berlin.de>
Subject: Text::Levenshtein and utf8 woes
Message-Id: <48n2lvFjttinU1@uni-berlin.de>

Hello utf8 wizards,

My series of utf8-related problem reports continues. Please have a look
at the output of the following script:

#!/usr/bin/perl			# uncommenting one or either of these
# binmode(STDOUT,":utf8");	# lines changes output significantly!
# use utf8;
use Text::Levenshtein qw(distance);
$lemma="Å tein";# the first letter is capital S with hacek, or U+0160
@candidates=("stein","Stein","steïn","Steïn","štein","šteïn");
for $candidate (@candidates) {
	print "$lemma -> $candidate: ".
		distance($lemma,$candidate)."\n";
	
}

Please note the edit distances; apparently the Text::Levenshtein module
works bytewise and not characterwise. To make things even more complicated,
the return values of 'distance' change with the settings of the first
lines. Again, perl is v.5.8.5 on a Linux box, everything utf8-enabled.

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


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

Date: 26 Mar 2006 08:36:31 GMT
From: <corff@zedat.fu-berlin.de>
Subject: Re: XML::Simple and utf8 woes
Message-Id: <48n24fFl13rrU1@uni-berlin.de>

Donald King <dlking@cpan.org> wrote:
: [Whoops, I did the post-vs-mail thing again.  Bad coder, no cookie.]

: FWIW, I've taken your original test case from the top of the thread and
: fixed it up.  It's now properly encoded in UTF-8, it uses both "use
: utf8" and "binmode(STDOUT, ':utf8')" to fix the problem, and I fixed it
: to run under "use strict" and "use warnings" while I was in there.  You
: can download it at <http://chronos-tachyon.net/~chronos/corff.pl>.

Hi Donald,

Thank you _very_ much for the fixed code. I ran it, and to no avail. The
problems remain. Can you tell me which environment the code worked for you?

My environment:

perl -v states:
perl v5.8.5 built for i386-linux-thread-multi

echo $LANG states:
en_US.UTF-8

in vim, opening the file in utf8 encoding succeeds (and displays correctly)

When running the file from the command line
 ./corff.pl

I get:
1) broken output of the print statement
2) over-interpreted representations o utf8 data in the output file w.xml.

If I disable _both_ the 
# use utf8;
 ...
# binmode(STDOUT, ":utf8");

lines,

the output of the print statement is _correct_ (accented characters
show properly), whereas the output of the w.xml file is still garbage.

If, in a fit of desperation, I modify the output of XMLout() with
NumericEscape=>2, all I get in the output is that, eg. a umlaut of
Morgend&auml;mmerung (sorry for this encoding-independet symbolic
notation here!) is represented as &#195;&#164; which happens to be the
decimal values of the two octets comprising U+00e4, or Latin small a
with umlaut.

I've already considered to suffer silently from now onwards and to write
a small filter that replaces all theses bytes in the final output, but
then, I think this is deeply unsatisfying.

Thanks again,
Oliver.

PS: A small truth table when using utf8 and the binmode statements:

	use utf8	binmode
	yes		yes		print fails, XMLout fails
	no		yes		print fails, XMLout fails
	yes		no		print succeeds, XMLout fails
	no		no		print succeeds, XMLout fails

We see that the utf8 pragma doesn't change anything even though the
data section of my script is utf8-material whereas binmode (STDOUT,':utf8')
seems to have the opposite effect of what it claims.

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


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

Date: Sun, 26 Mar 2006 11:45:30 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: XML::Simple and utf8 woes
Message-Id: <qrn50e.sm.ln@teal.hjp.at>

corff@zedat.fu-berlin.de wrote:
> Donald King <dlking@cpan.org> wrote:
> : <http://chronos-tachyon.net/~chronos/corff.pl>.
> 
> Thank you _very_ much for the fixed code. I ran it, and to no avail.
> The problems remain. Can you tell me which environment the code worked
> for you?
> 
> My environment:
> 
> perl -v states:
> perl v5.8.5 built for i386-linux-thread-multi
> 
> echo $LANG states:
> en_US.UTF-8
> 
> in vim, opening the file in utf8 encoding succeeds (and displays
> correctly)

I assume that your terminal is in UTF-8 mode, too, then. You could
verify that by invoking "cat corff.pl" and checking whether it looks
correct.


> When running the file from the command line
> ./corff.pl
> 
> I get:
> 1) broken output of the print statement
> 2) over-interpreted representations o utf8 data in the output file
> w.xml.

It works for me on FC3 (which is what you are using, too, if I remember
one of your previous posts correctly).

XML::Simple doesn't parse XML itself. Which XML parser are you using? 
I use XML::LibXML.

For reference, here is the output of
rpm -qa | grep perl-XML 
on this machine.

perl-XML-NamespaceSupport-1.08-6
perl-XML-LibXML-1.58-1
perl-XML-Dumper-0.71-2
perl-XML-SAX-0.12-7
perl-XML-Encoding-1.01-26
perl-XML-Grove-0.46alpha-27
perl-XML-Parser-2.34-5
perl-XML-Twig-3.13-6
perl-XML-LibXML-Common-0.13-7


> If, in a fit of desperation, I modify the output of XMLout() with
> NumericEscape=>2, all I get in the output is that, eg. a umlaut of
> Morgend&auml;mmerung (sorry for this encoding-independet symbolic
> notation here!) is represented as &#195;&#164;

This is definitely wrong. It should be only one entity (&#228; in this
case). So probably your parser parses the file as ISO-8859-1 instead of
UTF-8 or passes the "raw" strings on instead of converting them into
perl's internal utf-8 representation.

> I've already considered to suffer silently from now onwards and to
> write a small filter that replaces all theses bytes in the final
> output, but then, I think this is deeply unsatisfying.

Don't. It looks like the error happens on input, so if you have to
resort to such crude hacks, replace the bytes just after reading the
input.

        hp

-- 
   _  | Peter J. Holzer    | Löschung von at.usenet.schmankerl?
|_|_) | Sysadmin WSR/LUGA  | 
| |   | hjp@hjp.at         | Diskussion derzeit in at.usenet.gruppen
__/   | http://www.hjp.at/ |


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

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


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