in reply to creating a variable in an if statement

if( do { my @f; 1 == ( @f= one() ) || 1 == ( @f= two() ) } ) {

but that still leaves the body of your 'if' statement on separate lines. So you probably want to change your semicolons to commas, add parens where needed, maybe a few more 'do's so you can use a statement-modifier 'if' instead. The number of lines is really getting out of hand here. All that whitespace makes the multiple layers of nested parens and braces not nearly as interesting to stare at.

Update: Oh, the @f doesn't survive outside of the do { }.

if( my @f= do { my @g; 1 == ( @g= one() ) || 1 == ( @g= two() ) } ) {

- tye        

Replies are listed 'Best First'.
Re^2: creating a variable in an if statement ("do"s)
by ikegami (Patriarch) on Jan 22, 2008 at 19:59 UTC
    Your @f isn't accessible inside the if body.

    Update: He noticed and posted a "fix" while I was posting, but the fix is also broken. @f doesn't equal @g as it should.

      Somebody who makes rampant updates to so many of their nodes after posting might want to check for updates (actually noted as such) from others before replying or, horror, wait a few minutes.1 :)

      1 I think it is unlikely that you started replying before my update was posted as I refreshed to see my update, then refreshed for other reasons and saw your node had been updated (with no notice) and you hadn't replied yet. So after my update you made your own update and then replied to my node based on a version from before your last update. But I give up trying to update/reply fast enough for you. I'll check back after a few hours and assume your node content won't expand several fold w/o comment (yes, I've seen that happen with your nodes more than once, as I've mentioned to you before) from that point and thus it might be safe to reply/update if any response is warranted. (:

      - tye        

        I didn't post the reply to your node after I noticed that you corrected yourself. What an odd thing to claim, since no one would gain from that. The delay was surely due to taking the time to verify that your solution didn't work before posting.

        By the way, the silent update to reply to the OP was to include code that accidentally wasn't pasted in from the editor I used to compose the reply. It happened as soon as soon as the browser showed me the posted node and before I looked to see if anyone else had posted other replies. (This time. I'm not denying other additive updates, but always before anyone replies.)