Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: perldelta unclear on 'given's fate

by toolic (Chancellor)
on Jan 04, 2014 at 15:20 UTC ( #1069292=note: print w/ replies, xml ) Need Help??


in reply to perldelta unclear on 'given's fate

The current (5.18.0) perlsyn refers to given as "highly experimental". But, it also implies that foreach can be used in its place and is "non-experimental".


Comment on Re: perldelta unclear on 'given's fate
Select or Download Code
Re^2: perldelta unclear on 'given's fate
by morelenmir (Sexton) on Jan 04, 2014 at 15:31 UTC

    Yep, sure enough. That method of using 'foreach' looks to be almost identical to 'given' and provides nearly the same results. Although I will say manhandling 'foreach' to work like this seems more of bodge than having a proper 'switch' analogue.

    For now I'll follow you're advice toolic and swap over to 'foreach' until it is clear one way or the other if 'given' is going to make the cut.

    Reading that "perlsym" page and indeed, other posts here and at "stackoverflow" I get the feeling there is a fair bit of hostility towards poor old 'given/when'. Can you fill me in on why that might be?

    However... On trying it I still get warnings for 'when'. So... I guess the safest thing is just to trudge on with an ugly if/elsif construct for now.

        Going from that discussion it looks like a good part of 'given's usefulness is centred on smartmatch... Which I don't use in any other way, therefore perhaps 'given' is not all that important after all.

        At the end of the day I suppose I would just like a perl 'switch/case/default' because I am very used to that way of thinking and controlling execution.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1069292]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2014-07-24 03:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (156 votes), past polls