Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re^2: v5.36 syntax error around given/when

by ibm1620 (Pilgrim)
on Jun 10, 2022 at 14:01 UTC ( #11144659=note: print w/replies, xml ) Need Help??

in reply to Re: v5.36 syntax error around given/when
in thread v5.36 syntax error around given/when

Thanks! So, in order to allow my method of processing command line options to continue to work while using the v5.36 features, I can write:
use v5.36; use feature qw/switch/; no warnings "experimental::smartmatch"; no warnings "experimental::for_list"; for my ( $opt, $val ) (%$opts ) { given ($opt) { when ('h') { HELP_MESSAGE(); } when ('v') { ++$verbose; } when ('r') { ++$recursive; } when ('c') { ++$confirm; } when ('f') { ++$force; } default { die "*** BUG: no handler for -$opt.\n"; } } }
To me, this reads the best. I guess that if given goes away I'll replace it with for .. reluctantly, because "for" has always implied looping to me.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2022-10-05 22:26 GMT
Find Nodes?
    Voting Booth?
    My preferred way to holiday/vacation is:

    Results (25 votes). Check out past polls.