[27499] in Perl-Users-Digest
Perl-Users Digest, Issue: 9090 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 25 21:05:48 2006
Date: Sat, 25 Mar 2006 18:05:03 -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, 25 Mar 2006 Volume: 10 Number: 9090
Today's topics:
Re: file renamer... request feedback <rvtol+news@isolution.nl>
Re: Semi OT: Debugging with Speech, Smart Spoken Repres <vtatila@mail.student.oulu.fi>
Re: short form for (defined $x and defined $y and ... ) <uri@stemsystems.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 25 Mar 2006 19:54:12 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: file renamer... request feedback
Message-Id: <e047aj.1g4.1@news.isolution.nl>
TOC schreef:
> Dr.Ruud:
>> if ($_ ne $o)
>> {
>> if (-e $_) {...} # pre-existance
>> elsif (rename $o, $_) {...} # try rename
>> else {...} # failed
>> }
>
> ok, first of all I don't understand the ... can you give me a link to
> where it is documented?
Those are meant as ellipses, to be replaced by any code you fancy.
> here is the current state of the script, is this what you had in mind?
Yes. Maybe you also want to print that you skipped some file, if ($_ eq
$o).
--
Affijn, Ruud
"Gewoon is een tijger."
echo 014C8A26C5DB87DBE85A93DBF |perl -pe 'tr/0-9A-F/JunkshoP cartel,/'
------------------------------
Date: Sun, 26 Mar 2006 01:07:31 +0200
From: "Veli-Pekka Tätilä" <vtatila@mail.student.oulu.fi>
Subject: Re: Semi OT: Debugging with Speech, Smart Spoken Representation
Message-Id: <e04ifv$bta$1@news.oulu.fi>
Ilya Zakharevich wrote:
> As I said, no need to modify the debugger. Just set compactDump
I just tried the compactDump option and it works like a charm, thanks. It
gets most short arrays on one line without the indeces.
> never managed to make "deeply nested" stuff printed "nice"
I could say the same. Especially if you have subtrees with a lot of children
and would like to see all the sibling nodes at once. Here's an example of a
parse tree, that would be both visually and aurally hard to represent as
nested hashes:
http://www.tol.oulu.fi/kurssit/okp/Luennot/Kuvat/Johtopuu.jpg
I do have an ASCII representation I reconstructed with magnification. For
the nodes it lists their level, parent, siblings and the graphical ordering
but it is far from pretty. The above image looks like this in text:
1 assign to id, equals, expr
2 id of assign to x, preceeds equals, expr
2 expr of assign to id, asterisk, expr, follows id, equals
3 id of expr to x, between x and asterisk, expr
3 x of id, preceeds id, asterisk, expr
3 expr of expr to left paren, expr, right paren, follows id, asterisk
4 expr of expr to id, plus, expr, between x, left paren and right paren
4 x of id, preceeds left paren, expr, right paren
5 id of expr to y, preceeds plus, expr
5 expr of expr to id, follows id, plus
6 y of id, preceeds id
6 id of expr to z, follows y
7 z of expr
Even though the representation is rather formal, it'll only do for
relatively simple, distinctly tree-like structures. I guess it would be hard
to generalize for all structures composed of arrays and hashes. WHen reading
code with speech, most readres apart from Jaws for Windows, cannot read
indentation or visual layout sensibly. So giving enough context in text and
imposing structure by pauses or beeps is a major challenge.
> I think most of your "Screen Readers are Stupid" complaints will be
> satisfied by PerlDB "addons".
I'm along the same lines mostly. IT is quite sad really. IT wouldn't be
awfully difficult to build some more intelligence to these readers say with
plug-ins. Yet the market for programming blind folks, let alone for those
doing it in Perl, is so small that you don't make much money with such
additions. I've been thinking of how program code could be read aloud very
well and have some skeletal guidelines for c-like languages. I'll post the
list at the end.
> 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.
Now we're talking business, that is you hit the nail on the head. This is
exactly what I'm after when I talked about regexp searching bits of code
lines.
> This can be easily done by aliases
Can these aliases span multiple lines or statements? That would be a great
way to extend the debugger. Particularly, if you can put the commands in
files. That way, should I need to use someone else's debugger, I can simply
plug-in my own config file and be moderately happy,
> if PerlDB provides enough helper functions to make writing the aliases
I think there are some nice funcs documented on the DB man page. I'll start
in there. I've also taken a look at the db.pm source file.
>> d) Inability of GUI-readers to distinguish multi-column layout in the
>> console.
> You mean the "concise" help screen? Will this be better:
> List/search source lines: Control script execution:
> l [ln|sub] List source code | T Stack trace
> - or . List previous/current line| s [expr] Single step [in expr]
> v [line] View around line | n [expr] Next, steps over subs
> f filename View source in file | <CR/Enter> Repeat last n or s
<snip>
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?
> For seeing customers, we can add some color for the added "|" line to
> make it stnd out better.
That could be one option. Which reminds me though I'm legally blind and use
speech primarily, I've still got a bit of sight and can use heavy
full-screen magnification, too. I ordinarily use both when examining code so
it is not as difficult as it would seem by the screen readder prompts alone.
Still, say color, isn't much help to me, though some users might find it a
great aid. Syntax highlighting, for instance, means a drop in contrast and
thus poorer readability. This is most definitely OT but in case you are
interested in my sight-situation, I've got a page attempting to describe how
and what I see. URL:
http://www.student.oulu.fi/~vtatila/sight.html
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. HOpe this brief form makes
sense, they are primarily for myself at this point. Java and C should go by
these rules nicely and many of them apply to Perl, too. Perl is such a rich
language that I didn't wish to start with Perl in specifying the basic
rules, however. Formatting is tabular using spaces so a fixed width font
would do best. Here we go:
operator prompt
+ plus
- minus
* times
/ per
% modulo
++a pr-einc
--a pre-dec
a++ post-inc
a-- post-dec
.f f field
->f f field
.f() f
->f() f
(t) cast to t
< less than
> greater than
<= at least
>= at most
== equals
!= differs
= is
op= op is
a?:c cond a ? true b : false c
! not
&& and
|| or
& bit and
| bit or
^ xor
~ negation
<< left shift
>> right shift
// c comment c
/*c*/ comment block c end
f{ block
} end f
{ bear block
a[x] a at x
x1,x2 x1 comma op x2
t* pointer to t
t& ref to t
&i i's address OR address of i
*i deref i OR value of i
Omission rules for punctuation:
code prompt argument
a.f() a f void function, dot implied
a.f(a, b) a f a PAUSE b simple param list
if(cpmd) if cond parens implied by context
else if(cond) else if cond parens implied by context
else(cond) else cond parens implied by context
while(cond) while cond parens implied by context
for(exps) for exps parens implied by context
switch(expr) switch expr parens implied by context
(exp) op a parens exp end op explicite parens: precedence
case label: case label colon implied by context
lab: statement label lab statement rare, so explicit
x1;<nl>x2; x1 PAUSE x2 statements pause delimited
x1; x2; <nl> x1 PAUSE x2 line emphasizes related statements
; nop has meaning as a no-op
for(x;y;z) for x PAUSE y PAUSE z statements implied by pauses
for(x : y) for x in y audible equivalent of colon
x<type> x of type prompt taken from generics
a[j][k] a at j k for simple Expressions
[x1][x2] at [ROW] x1 [COL] x2 more explicit inddeces
{r1},{r2} row r1 row r2 {} no blocks in inits
--
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: Sat, 25 Mar 2006 14:28:34 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: short form for (defined $x and defined $y and ... )?
Message-Id: <x78xqyiasd.fsf@mail.sysarch.com>
>>>>> "MD" == Markus Dehmann <markus.dehmann@gmail.com> writes:
MD> my ($x,$y,$z) = $userInput =~ m/(.+?)\s\+\s(.+?)\s=\s(.+)/;
MD> die("wrong input format") unless(defined $x and defined $y and defined $z);
first rule, always check regexes for success before you use the
values. other replies have shown how to do this.
now let's look at that regex. all the grabs are .+'s which means they
all have at least one char and nothing is optional so they all must grab
something if the whole regex matches. that means you can't get an undef
grabbed value if that regex matches. so your defined checks are
redundant and can be removed provided you check the regex for
success. so i was right about your checking defined on all of them.
my ($x,$y,$z) = $userInput =~ m/(.+?)\s\+\s(.+?)\s=\s(.+)/ or
die 'lousy input' ;
look mommy! no calls to defined! :)
MD> Okay, but you're right, maybe I could change the design. Maybe
MD> something like this:
MD> if( $userInput =~ m/(.+?)\s\+\s(.+?)\s=\s(.+)/ ){
MD> ($x,$y,$z) = ($1,$2,$2);
MD> }
MD> else{
MD> die("wrong input format");
MD> }
MD> But again, this is longer, and I find my first version more intuitive.
or look at my version above. when you do something very simple based on
a boolean, then condtional modifiers (trailing if/unless) or boolean ops
(and, or ) are cleaner. they also save blocks which cost something to
enter. and extra indents and {} waste pixels and those are a precious
resource!
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
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 9090
***************************************