develooper Front page | perl.perl5.porters | Postings from September 2012

Auto-chomp (was Re: given/when/~~ "final" thoughts (ha ha ha))

Thread Next
From:
David Golden
Date:
September 25, 2012 09:26
Subject:
Auto-chomp (was Re: given/when/~~ "final" thoughts (ha ha ha))
Message ID:
CAOeq1c8N1xN4_SahD=45TqZNFNt8ZXF3Byg+zQpF9UbhbpEJrw@mail.gmail.com
On Tue, Sep 25, 2012 at 10:41 AM, Smylers <Smylers@stripey.com> wrote:
> Damian previously gave an example where == matching would work but eq
> wouldn't, because $_ has been populated with readline and has a "\n":
>
>   while (readline) {
>       when (undef)    { say 'done'; last;  }
>       when (0)        { say 'must be +ve'; }
>       when (any 1..9) { say 'digit';       }
>       default         { die 'horribly';    }
>   }

I'm trying to think how often I actually want the "\n" or want it
chomped.  If there were a ":chomp" layer, I might use it a lot.

David


-- 
David Golden <xdg@xdg.me>
Take back your inbox! → http://www.bunchmail.com/
Twitter/IRC: @xdg

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About