The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Ralph (5) [Avatar] Offline
#1
Hi,

I'm your posterchild UNIX scripter and I'm baffled.

I guess I don't follow the logic of the (sometimes written with 'or' and sometimes with 'and') LAST loop condition. (pages 352 top vs 353 top.)

Maybe it's obvious but not right now...

THANK YOU!
Ralph
Ralph (5) [Avatar] Offline
#2
Re: 10.6.3 (or last) vs (and last)
Ralph has had his EUREKA moment.
left to right precedence does it all.

Thanks Ralph
tmaher (37) [Avatar] Offline
#3
Re: 10.6.3 (or last) vs (and last)
Seems like you figured it out, but for the benefit of other readers, it comes down to this.
The loops at the top of p. 352 and p. 353 are both designed to execute <TT>last</TT> when the <TT>condition</TT> is False, using <TT>or last</TT>, but, the "compound condition" being tested on p. 353 requires the logical <TT>and</TT> to check that both of the criteria for its condition are True.


(<TT>condition) or last;</TT> # p. 352


(<TT>$answer ne 'y' and $answer ne 'n') or last;</TT> # p. 353