spx2 has asked for the wisdom of the Perl Monks concerning the following question:

Is there any module or way to use the given/when mechanism for perl 5.8.x ? I will probably be forced to use that version of perl while I write my code on 5.10 and I'm heavily making use of given/when lately so I'd like to know if there's any substitute for it there.

Thank you,

Stefan

Replies are listed 'Best First'.
Re: use feature "switch" for 5.8
by ikegami (Patriarch) on Mar 23, 2009 at 03:17 UTC

    use feature doesn't add given. It simply allows it to be used. It's as ingrained into Perl as the addition operator.

    Using source filters, it's possible to change Perl's grammar. That's what Switch does, which is probably the closest there is to 5.10's switch in older versions.

    However, Switch introduces impossible to debug problems when its source filter doesn't correctly parse the Perl source, and the syntax and semantics are different than 5.10's.

    I strongly advise you to avoid using it. Upgrade to 5.10 or tough without given.