diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-10-18 10:22:44 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-10-18 10:22:44 +0200 |
commit | 22bc907ae9b9703f36931e4de30ca013ddb732f6 (patch) | |
tree | 0ff080eae09a2b0970848bf8966f94d8cb7b7738 /ext/File-Glob | |
parent | 1d89eaefc9389231706769754db5b13acbd4e25d (diff) | |
download | perl-22bc907ae9b9703f36931e4de30ca013ddb732f6.tar.gz |
Convert File::Glob::import to use given/when.
Diffstat (limited to 'ext/File-Glob')
-rw-r--r-- | ext/File-Glob/Glob.pm | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/ext/File-Glob/Glob.pm b/ext/File-Glob/Glob.pm index 5ae3c6db43..63657fbe29 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; } |