page 124 of the camel book

page 124 of the camel book

am 26.11.2007 06:14:31 von Wade Ward

I am trying to write something in perl that has on outer while, an inner
while, and an if block within the inner while that causes execution to pass
from the inner block to the outer.

I think that the syntax I'm looking for is on page 124 in the first two code
snippets:

{
do {
last if $x = $y ** 2;
# do something here
} while $x++ <= $z;
}


and DO_LAST ...DO_NEXT immediately following.

1) Don't you want '==' instaed of '=' on the test condition?

2) What are the outside curly braces doing here? What do they belong to?

Control structures in perl look like clothing on the Dallas Cowboy
cheerleaders.
--
wade ward

wade@zaxfuuq.net
435 -838-7760



----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

Re: page 124 of the camel book

am 26.11.2007 08:17:46 von krahnj

Wade Ward wrote:
>
> I am trying to write something in perl that has on outer while, an inner
> while, and an if block within the inner while that causes execution to pass
> from the inner block to the outer.
>
> I think that the syntax I'm looking for is on page 124 in the first two code
> snippets:
>
> {
> do {
> last if $x = $y ** 2;
> # do something here
> } while $x++ <= $z;
> }
>
> and DO_LAST ...DO_NEXT immediately following.
>
> 1) Don't you want '==' instaed of '=' on the test condition?

It depends on what the variables $x and $y are doing inside the loop.


> 2) What are the outside curly braces doing here? What do they belong to?

They create a loop so that 'last' will work, do {} is not a loop.

perldoc perlsyn



John
--
use Perl;
program
fulfillment

Re: page 124 of the camel book

am 26.11.2007 09:40:09 von Wade Ward

"John W. Krahn" wrote in message
news:474A7303.4E10C53B@telus.net...
> Wade Ward wrote:
>>
>> I am trying to write something in perl that has on outer while, an inner
>> while, and an if block within the inner while that causes execution to
>> pass
>> from the inner block to the outer.
>>
>> I think that the syntax I'm looking for is on page 124 in the first two
>> code
>> snippets:
>>
>> {
>> do {
>> last if $x = $y ** 2;
>> # do something here
>> } while $x++ <= $z;
>> }
>>
>> and DO_LAST ...DO_NEXT immediately following.
>>
>> 1) Don't you want '==' instaed of '=' on the test condition?
>
> It depends on what the variables $x and $y are doing inside the loop.
>
>
>> 2) What are the outside curly braces doing here? What do they belong
>> to?
>
> They create a loop so that 'last' will work, do {} is not a loop.
>
> >
>
Yeah, it might well be in something called perlsyn that I can bring up in an
untoward dos fashion. What's the answer to the Perl question in terms of
its primary reference, the camel book in 17 pieces on my bed?

do is a gloop. I call it a while control for usenet purposes.

Thanks for your response. The code that I'm going to hook up with this
control mechanism follows.

###### fortran prog to translate

# program contract4

# implicit none

#integer, parameter :: dp=kind(1.0d0)
#real(kind=dp):: x_calc, x_sought, base, term
#real(kind=dp):: penultimate
#integer:: power

#x_calc = 5.3_dp
#x_sought = log(160.0_dp)/log(2.0_dp)
#write (*, '(A , F20.15)') " sought = ", x_sought
#base= .5_dp
#power = 1

#outer: do
#term = base**power

#inner: do
#penultimate = x_calc
#x_calc = x_calc + term


#exceed_target: if (10_dp*(2.0_dp**x_calc) .gt. 1600.0_dp) then
#x_calc = penultimate
#power = power + 1
#write (*, '(A , F20.15)') " current= ", x_calc
#write (*, '(A , F20.15)') " term = ", term
#write (*, '(A , I4)') " power = ", (power-1)
#exit
#endif exceed_target

#end do inner
#if (power .gt. 35) exit
#end do outer

#end program contract4


# current= 7.321928094880422
# term = 0.000000000029104
# power = 35
# final = 7.321928094880422
# sought = 7.321928094887362
# 1.2345678911234567892123456.

###### fortran prog to translate

# perl contract53.pl
# perl contract19.pl 2>text55.txt >text56.txt

__END__

--
wade ward

wade@zaxfuuq.net
435 -838-7760



----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

Re: page 124 of the camel book

am 26.11.2007 13:41:31 von Tad McClellan

Wade Ward wrote:
>
> "John W. Krahn" wrote in message
> news:474A7303.4E10C53B@telus.net...
>> Wade Ward wrote:


>>> {
>>> do {
>>> last if $x = $y ** 2;
>>> # do something here
>>> } while $x++ <= $z;
>>> }


>>> 2) What are the outside curly braces doing here? What do they belong
>>> to?
>>
>> They create a loop so that 'last' will work, do {} is not a loop.

> Yeah, it might well be in something called perlsyn that I can bring up in an
> untoward dos fashion. What's the answer to the Perl question in terms of
> its primary reference, the camel book in 17 pieces on my bed?


The Camel book is not the primary reference for Perl.

The primary reference for Perl is the documentation that is
included with the perl distribution.


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"

Re: page 124 of the camel book

am 26.11.2007 17:48:25 von jl_post

On Nov 25, 10:14 pm, "Wade Ward" wrote:
>
> I think that the syntax I'm looking for is on page 124 in the first two code
> snippets:
>
> {
> do {
> last if $x = $y ** 2;
> # do something here
> } while $x++ <= $z;
>
> }
>
> and DO_LAST ...DO_NEXT immediately following.
>
> 1) Don't you want '==' instaed of '=' on the test condition?


Well, that test condition is just for the sake of example. To be
honest, if I came across it in some code I was reviewing, I'd
immediately suspect that it was a bug and then carefully review the
code around it to confirm to suspicions. But since it's example code,
it might as well say "last if $blah_blah_blah;" since a complete
working program isn't given.


> 2) What are the outside curly braces doing here? What do they belong to?


The "last", "next", and "redo" statements are nice because they can
jump out of (or around in) blocks enclosed by curly braces. For
example, you can have a block of code like this:

{
# do something here
last if $x == 0;
# do something here that involves dividing by $x
}

In this example, the program execution will jump out of the block mid-
way if $x happens to be zero, preventing the second-half of the block
to be executed. Programmers familiar with other languages might write
it like this:

// Do something here.

if (x != 0)
{
// Do something here that involves dividing by x
}

While this approach definitely works, it kind of "divides" the
original block in two and makes it look like there are two separate
blocks of code, each independent of the other. This might tempt
future maintainers to insert totally unrelated code between the two
blocks.

I'm not saying that the second approach is bad; I'm just saying
that Perl programmers have the option of writing it the first way,
which they might use if they want to give future maintainers the
impression that the code all belongs in one block and should not be
separated.

Now, if you look up "perldoc -f last", you'll see that "last"
cannot be used to exit a "do-block" ("perldoc -f do" also says that).
So back to your question:

> 2) What are the outside curly braces doing here? What do they belong to?

The outside curly braces are to provide a way of controlling where the
"last" keyword will jump to if/when it is invoked. "last" will NOT
jump to the end of the innermost braces since they belong to a
do{}while loop. Therefore, an extra set of curly braces (surrounding
the do{}while loop) is needed to completely jump out of the loop.

I hope this helps, Wade.

-- Jean-Luc

Re: page 124 of the camel book

am 27.11.2007 15:46:54 von Lars Haugseth

* "jl_post@hotmail.com" wrote:
>
> On Nov 25, 10:14 pm, "Wade Ward" wrote:
> >
> > I think that the syntax I'm looking for is on page 124 in the first
> > two code snippets:
> >
> > {
> > do {
> > last if $x = $y ** 2;
> > # do something here
> > } while $x++ <= $z;
> >
> > }
> >
>
[snip]
>
>
> > 2) What are the outside curly braces doing here? What do they
> > belong to?
>
> The outside curly braces are to provide a way of controlling where the
> "last" keyword will jump to if/when it is invoked. "last" will NOT
> jump to the end of the innermost braces since they belong to a
> do{}while loop. Therefore, an extra set of curly braces (surrounding
> the do{}while loop) is needed to completely jump out of the loop.

I find it more readable to put the extra set of curly braces
inside the do-while:

do {{ # allow early exit using 'last'
last if $x = $y ** 2;
# do something here
}} while $x++ <= $z;

Then again, I find it even more readable to avoid using do-while
altogether...

--
Lars Haugseth

"If anyone disagrees with anything I say, I am quite prepared not only to
retract it, but also to deny under oath that I ever said it." -Tom Lehrer

Re: page 124 of the camel book

am 27.11.2007 17:24:18 von jl_post

On Nov 27, 7:46 am, Lars Haugseth wrote:
>
> I find it more readable to put the extra set of curly braces
> inside the do-while:
>
> do {{ # allow early exit using 'last'
> last if $x = $y ** 2;
> # do something here
> }} while $x++ <= $z;


That won't work, Lars. With "last", the braces have to be outside
the do{}while loop, or else the do{}while loop will keep iterating.
Let me explain with an example:

my $x = 0;
do {{
last if $x == 2;
print $x;
}} while $x++ < 5;

This looks like we want to break out of the loop when $x equals 2, but
in fact we just jump to the end of it, and let the while() condition
"re-loops" us back to the top of the loop, setting $x to 3. In this
case, "last" can be replaced with "next" and nothing will change.
Basically, the above code will print "01345". ("345" is printed
because the loop is never completely broken out of when $x == 2.)

If we want to completely break out of the loop when $x is 2, we
would write something like this instead:

my $x = 0;
{
do {
last if $x == 2;
print $x;
} while $x++ < 5;
}

This code prints only "01", showing that the loop is fully exited when
$x is 2.


> Then again, I find it even more readable to avoid using do-while
> altogether...


Yes, do{}while loops can be a bit confusing, but they're not that
bad if you avoid using "next" and "last" (and "redo") in them. But if
you really want to use them inside a do{}while loop, you can; you just
have to use one of the work-arounds mentioned on page 124 of the Camel
book.

-- Jean-Luc

Re: page 124 of the camel book

am 27.11.2007 17:45:22 von Lars Haugseth

* "jl_post@hotmail.com" wrote:
>
> On Nov 27, 7:46 am, Lars Haugseth wrote:
> >
> > I find it more readable to put the extra set of curly braces
> > inside the do-while:
> >
> > do {{ # allow early exit using 'last'
> > last if $x = $y ** 2;
> > # do something here
> > }} while $x++ <= $z;
>
>
> That won't work, Lars. With "last", the braces have to be outside
> the do{}while loop, or else the do{}while loop will keep iterating.

You are right. I wrote a quick test before I posted, modifying a
condition "next if $x > 2" to use last instead of next, and as the
rest of the loop wasn't executed I assumed it work. My bad, sorry!

--
Lars Haugseth

"If anyone disagrees with anything I say, I am quite prepared not only to
retract it, but also to deny under oath that I ever said it." -Tom Lehrer

Re: page 124 of the camel book

am 28.11.2007 02:11:28 von Wade Ward

wrote in message
news:0adffdf2-93fb-4867-bca7-23d460e606c1@s19g2000prg.google groups.com...
> On Nov 27, 7:46 am, Lars Haugseth wrote:
>>
>> I find it more readable to put the extra set of curly braces
>> inside the do-while:
>>
>> do {{ # allow early exit using 'last'
>> last if $x = $y ** 2;
>> # do something here
>> }} while $x++ <= $z;
>
>
> That won't work, Lars. With "last", the braces have to be outside
> the do{}while loop, or else the do{}while loop will keep iterating.
> Let me explain with an example:
>
> my $x = 0;
> do {{
> last if $x == 2;
> print $x;
> }} while $x++ < 5;
>
> This looks like we want to break out of the loop when $x equals 2, but
> in fact we just jump to the end of it, and let the while() condition
> "re-loops" us back to the top of the loop, setting $x to 3. In this
> case, "last" can be replaced with "next" and nothing will change.
> Basically, the above code will print "01345". ("345" is printed
> because the loop is never completely broken out of when $x == 2.)
>
> If we want to completely break out of the loop when $x is 2, we
> would write something like this instead:
>
> my $x = 0;
> {
> do {
> last if $x == 2;
> print $x;
> } while $x++ < 5;
> }
>
> This code prints only "01", showing that the loop is fully exited when
> $x is 2.
>
>
>> Then again, I find it even more readable to avoid using do-while
>> altogether...
>
>
> Yes, do{}while loops can be a bit confusing, but they're not that
> bad if you avoid using "next" and "last" (and "redo") in them. But if
> you really want to use them inside a do{}while loop, you can; you just
> have to use one of the work-arounds mentioned on page 124 of the Camel
> book.
Thanks for the elaboration, Picard.

Control loops are strange things. For better or worse, I'm gonna try to get
back on the perl horse that has bucked me off fifty times already on this
one simple prog. I was astonished when I couldn't
break;
, like you do in C.

That's when I started throwing the camel book around like an angry gorilla.
Page 124 is on the largest-surviving chunk.

cheers,
--
wade ward

wade@zaxfuuq.net
435 -838-7760



----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

Re: page 124 of the camel book

am 28.11.2007 02:43:40 von jurgenex

Wade Ward wrote:
> already on this one simple prog. I was astonished when I couldn't
> break;
> , like you do in C.

May I suggest you take an introductory class in structured programming? Then
you don't need those remnants of goto.
Yes, there are rare circumstances where breaking out of a loop in its middle
seems to be convenient. But is never a necessity and usually indicates the
programmer is not all that familiar with modern program design.

> That's when I started throwing the camel book around like an angry
> gorilla. Page 124 is on the largest-surviving chunk.

Of course structured programming and good program design is independant of
the programming language used.

jue

Re: page 124 of the camel book

am 28.11.2007 02:54:41 von jurgenex

jl_post@hotmail.com wrote:
> If we want to completely break out of the loop when $x is 2, we
> would write something like this instead:
>
> my $x = 0;
> {
> do {
> last if $x == 2;
> print $x;
> } while $x++ < 5;
> }
>
> This code prints only "01", showing that the loop is fully exited when
> $x is 2.

Now, why so confusing? Wouldn't

my $x = 0;
while ($x <=5 and $x !=2) {
print $x;
$x++; # doing a $x++ as a side effect
# in the condition is poor style
}

work just as well with much less huff and puff?

jue

Re: page 124 of the camel book

am 28.11.2007 03:25:16 von Uri Guttman

>>>>> "JE" == Jürgen Exner writes:


JE> May I suggest you take an introductory class in structured
JE> programming? Then you don't need those remnants of goto.

ditto.

JE> Yes, there are rare circumstances where breaking out of a loop in
JE> its middle seems to be convenient. But is never a necessity and
JE> usually indicates the programmer is not all that familiar with
JE> modern program design.

i have always taught others to use smaller subs with return instead of
needing goto to get out of a deep loop. it usually is much cleaner. but
some coders stick to the 'exit only at the end of a sub' rule that was
pushed when structured programming was hot. i think that rule should be
ignored as early return is as useful as next/last inside a loop.

and i can't recall the last time i used a label or goto in perl (if
ever). i do use magic goto rarely but that is really a different beast.

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

Re: page 124 of the camel book

am 28.11.2007 09:22:04 von Wade Ward

"Jürgen Exner" wrote in message
news:gJ33j.14791$Jy1.3782@trndny02...
> Wade Ward wrote:
>> already on this one simple prog. I was astonished when I couldn't
>> break;
>> , like you do in C.
>
> May I suggest you take an introductory class in structured programming?
> Then you don't need those remnants of goto.
> Yes, there are rare circumstances where breaking out of a loop in its
> middle seems to be convenient. But is never a necessity and usually
> indicates the programmer is not all that familiar with modern program
> design.
I received my post-grad transcripts today. They begin with Jay Goldman and
end with a geometry class from the MN dept of edu in which I appear to have
gotten a D while having gotten an A in the like material from the dept of
math. Ask Carl.

Strange communists.

>> That's when I started throwing the camel book around like an angry
>> gorilla. Page 124 is on the largest-surviving chunk.
>
> Of course structured programming and good program design is independant of
> the programming language used.
I received my structured prog instruction from the Y in 1988. I would like
to talk somewhat of independacne, which anothr might render as indepedence.
--
wade ward

wade@zaxfuuq.net
435 -838-7760



----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

Re: page 124 of the camel book

am 29.11.2007 01:56:38 von Wade Ward

wrote in message
news:158c9e2e-e20a-441e-ab68-685a2362143f@i29g2000prf.google groups.com...
> On Nov 25, 10:14 pm, "Wade Ward" wrote:
>>
>> I think that the syntax I'm looking for is on page 124 in the first two
>> code
>> snippets:
>>
>> {
>> do {
>> last if $x = $y ** 2;
>> # do something here
>> } while $x++ <= $z;
>>
>> }
>>
>> and DO_LAST ...DO_NEXT immediately following.
>>
>> 1) Don't you want '==' instaed of '=' on the test condition?
>
>
> Well, that test condition is just for the sake of example. To be
> honest, if I came across it in some code I was reviewing, I'd
> immediately suspect that it was a bug and then carefully review the
> code around it to confirm to suspicions. But since it's example code,
> it might as well say "last if $blah_blah_blah;" since a complete
> working program isn't given.
>
>
>> 2) What are the outside curly braces doing here? What do they belong
>> to?
>
>
> The "last", "next", and "redo" statements are nice because they can
> jump out of (or around in) blocks enclosed by curly braces. For
> example, you can have a block of code like this:
>
> {
> # do something here
> last if $x == 0;
> # do something here that involves dividing by $x
> }
>
> In this example, the program execution will jump out of the block mid-
> way if $x happens to be zero, preventing the second-half of the block
> to be executed. Programmers familiar with other languages might write
> it like this:
>
> // Do something here.
>
> if (x != 0)
> {
> // Do something here that involves dividing by x
> }
>
> While this approach definitely works, it kind of "divides" the
> original block in two and makes it look like there are two separate
> blocks of code, each independent of the other. This might tempt
> future maintainers to insert totally unrelated code between the two
> blocks.
>
> I'm not saying that the second approach is bad; I'm just saying
> that Perl programmers have the option of writing it the first way,
> which they might use if they want to give future maintainers the
> impression that the code all belongs in one block and should not be
> separated.
>
> Now, if you look up "perldoc -f last", you'll see that "last"
> cannot be used to exit a "do-block" ("perldoc -f do" also says that).
> So back to your question:
>
>> 2) What are the outside curly braces doing here? What do they belong
>> to?
>
> The outside curly braces are to provide a way of controlling where the
> "last" keyword will jump to if/when it is invoked. "last" will NOT
> jump to the end of the innermost braces since they belong to a
> do{}while loop. Therefore, an extra set of curly braces (surrounding
> the do{}while loop) is needed to completely jump out of the loop.
>
> I hope this helps, Wade.
I'm experimenting with different options and think I have achieved a control
that can be adapted to suit the purpose at hand.

## contract55.pl
## one sided increasingly good guesses
## contributors: joe smith, jean luc


use strict;
use warnings;

#integer, parameter :: dp=kind(1.0d0)
#real(kind=dp):: x_calc, x_sought, base, term
#real(kind=dp):: penultimate
#integer:: power

my $x_calc = 5.3;
my $x_sought = 7.321928094887362;
my $base = .5;
my $term = -.00057;
my $ penultimate = -.00057;

my $power = 1;

do {{
$x_calc = $x_calc - 1;
# last if $x_calc < 0;
print STDOUT "x calc is $x_calc\n";
do {{
$x_sought = $x_sought - 1;
# last if $x_sought < 0;
print STDOUT "x sought is $x_sought\n";

}} until $x_sought < 0;
}} until $x_calc < 0;





print STDOUT "power is $power\n";
print STDOUT "base is $base\n";

# end output prelims

# code elided
# perl contract55.pl
# perl contract55.pl 2>text55.txt >text56.txt

__END__
#begin output prelims
x calc is 4.3
x sought is 6.32192809488736
x sought is 5.32192809488736
x sought is 4.32192809488736
x sought is 3.32192809488736
x sought is 2.32192809488736
x sought is 1.32192809488736
x sought is 0.321928094887362
x sought is -0.678071905112638
x calc is 3.3
x sought is -1.67807190511264
x calc is 2.3
x sought is -2.67807190511264
x calc is 1.3
x sought is -3.67807190511264
x calc is 0.3
x sought is -4.67807190511264
x calc is -0.7
x sought is -5.67807190511264
power is 1
base is 0.5
# end output

A couple things I have found interesdting:

{
You can stick this anywhere and have it run once

}

If you uncomment the last line with equivalent end conditions in last and
until
do {{
$x_sought = $x_sought - 1;
# last if $x_sought < 0;
print STDOUT "x sought is $x_sought\n";

}} until $x_sought < 0;
, you don't execute the ultimate print.
--
wade ward

wade@zaxfuuq.net
435 -838-7760



----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

Re: page 124 of the camel book

am 29.11.2007 03:37:55 von Uri Guttman

>>>>> "WW" == Wade Ward writes:

WW> do {{
WW> $x_calc = $x_calc - 1;

ever heard of --?

WW> # last if $x_calc < 0;
WW> print STDOUT "x calc is $x_calc\n";
WW> do {{
WW> $x_sought = $x_sought - 1;
WW> # last if $x_sought < 0;
WW> print STDOUT "x sought is $x_sought\n";

WW> }} until $x_sought < 0;
WW> }} until $x_calc < 0;

do while is bad enough in perl (rarely needed, i never use it) but
do/until is horrible. invert those boolean tests and use while. but
better would be to invert those into proper while loops.

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

Re: page 124 of the camel book

am 29.11.2007 23:34:07 von Michele Dondi

On Tue, 27 Nov 2007 18:11:28 -0700, "Wade Ward"
wrote:

>Control loops are strange things. For better or worse, I'm gonna try to get
>back on the perl horse that has bucked me off fifty times already on this
>one simple prog. I was astonished when I couldn't
>break;
>, like you do in C.

By all accounts, you can. What's the problem?


Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^ ..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,

Re: page 124 of the camel book

am 29.11.2007 23:36:01 von Michele Dondi

On Wed, 28 Nov 2007 01:43:40 GMT, "Jürgen Exner"
wrote:

>May I suggest you take an introductory class in structured programming? Then
>you don't need those remnants of goto.
>Yes, there are rare circumstances where breaking out of a loop in its middle
>seems to be convenient. But is never a necessity and usually indicates the
>programmer is not all that familiar with modern program design.

IIUC, this is much of a FUD attack. What's so bad about goto is that
it is unrestricted goto; OTOH last, next and redo are tamed forms of
goto and they just make for clearer syntax. I don't feel holding say a
$goon flag variable could be regarded as a superior solution.


Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^ ..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,

Re: page 124 of the camel book

am 29.11.2007 23:39:25 von Michele Dondi

On Thu, 29 Nov 2007 02:37:55 GMT, Uri Guttman
wrote:

> WW> do {{
> WW> $x_sought = $x_sought - 1;
> WW> # last if $x_sought < 0;
> WW> print STDOUT "x sought is $x_sought\n";
>
> WW> }} until $x_sought < 0;
> WW> }} until $x_calc < 0;
>
>do while is bad enough in perl (rarely needed, i never use it) but
>do/until is horrible. invert those boolean tests and use while. but
>better would be to invert those into proper while loops.

And do {{ ... }} until is... well, what's worse than "horrible"?


Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^ ..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,

Re: page 124 of the camel book

am 30.11.2007 01:01:27 von Uri Guttman

>>>>> "MD" == Michele Dondi writes:

MD> On Thu, 29 Nov 2007 02:37:55 GMT, Uri Guttman
MD> wrote:

WW> do {{
WW> $x_sought = $x_sought - 1;
WW> # last if $x_sought < 0;
WW> print STDOUT "x sought is $x_sought\n";
>>
WW> }} until $x_sought < 0;
WW> }} until $x_calc < 0;
>>
>> do while is bad enough in perl (rarely needed, i never use it) but
>> do/until is horrible. invert those boolean tests and use while. but
>> better would be to invert those into proper while loops.

MD> And do {{ ... }} until is... well, what's worse than "horrible"?

wardish?

he does seem to want to code in the worst way possible!

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