Wyrdweaver has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; use utf8; use 5.008008; # minimum perl version ## v5.8.8 ~ required for decent + basic Unicode support my @list = qw/ Foo bAR baZ /; if ( $] ge '5.016' ) { ## no critic ( ProhibitStringyEval RequireCheckingReturnValueOfEva +l ) eval q/@list = sort { ( CORE::fc $a ) cmp ( CORE::fc $b ) } @list; +/ } else { @list = sort { ( lc $a ) cmp ( lc $b ) } @list; } print qq/[ @list ]/,"\n";
It works but seems a bit crufty to me. I'd love to hear opinions or about any alternative formulations.
Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl version dependent code (updated)
by haukex (Archbishop) on Jan 24, 2019 at 20:29 UTC | |
by Laurent_R (Canon) on Jan 24, 2019 at 22:50 UTC | |
by haukex (Archbishop) on Jan 25, 2019 at 11:38 UTC | |
by Aldebaran (Curate) on Feb 03, 2019 at 22:13 UTC | |
by hippo (Archbishop) on Feb 04, 2019 at 09:29 UTC | |
by Aldebaran (Curate) on Feb 05, 2019 at 09:05 UTC | |
|
Re: Perl version dependent code
by tobyink (Canon) on Jan 24, 2019 at 23:05 UTC | |
by choroba (Cardinal) on Jan 25, 2019 at 10:40 UTC | |
|
Re: Perl version dependent code
by Anonymous Monk on Jan 25, 2019 at 17:22 UTC |