Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: perldelta unclear on 'given's fate

by toolic (Bishop)
on Jan 04, 2014 at 15:20 UTC ( [id://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".

Replies are listed 'Best First'.
Re^2: perldelta unclear on 'given's fate
by morelenmir (Beadle) 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1069292]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-19 02:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found