From 22bc907ae9b9703f36931e4de30ca013ddb732f6 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Mon, 18 Oct 2010 10:22:44 +0200 Subject: [PATCH] Convert File::Glob::import to use given/when. --- ext/File-Glob/Glob.pm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ext/File-Glob/Glob.pm b/ext/File-Glob/Glob.pm index 5ae3c6d..63657fb 100644 --- a/ext/File-Glob/Glob.pm +++ b/ext/File-Glob/Glob.pm @@ -5,6 +5,7 @@ our($VERSION, @ISA, @EXPORT_OK, @EXPORT_FAIL, %EXPORT_TAGS, $AUTOLOAD, $DEFAULT_FLAGS); require XSLoader; +use feature 'switch'; @ISA = qw(Exporter); @@ -42,17 +43,19 @@ sub import { require Exporter; my $i = 1; while ($i < @_) { - if ($_[$i] =~ /^:(case|nocase|globally)$/) { - splice(@_, $i, 1); - $DEFAULT_FLAGS &= ~GLOB_NOCASE() if $1 eq 'case'; - $DEFAULT_FLAGS |= GLOB_NOCASE() if $1 eq 'nocase'; - if ($1 eq 'globally') { - local $^W; + given ($_[$i]) { + $DEFAULT_FLAGS &= ~GLOB_NOCASE() when ':case'; + $DEFAULT_FLAGS |= GLOB_NOCASE() when ':nocase'; + when (':globally') { + no warnings 'redefine'; *CORE::GLOBAL::glob = \&File::Glob::csh_glob; } + # We didn't match any special tags, so keep this argument. + ++$i; next; } - ++$i; + # We matched a special argument, so remove it + splice @_, $i, 1; } goto &Exporter::import; } -- 2.7.4