grep /^${var}$/ is a little silly, just use $_ eq $var
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / Completion.pm
index b546488..ad7c25f 100644 (file)
@@ -54,9 +54,9 @@ around 'eval' => sub {
     my @ret = $self->$orig($line);
     
     # the namespace of the loaded module
-    if ($line =~ /use\s+(\S+)/) {
+    if ($line =~ /\buse\s+(\S+)/) {
         my $module = $1;
-        foreach my $keyword (keys %{$self->get_namespace($module)}) {
+        foreach my $keyword (keys %{$self->get_namespace($module) || {}}) {
             $self->push_completion($keyword);
         }
     }
@@ -67,7 +67,7 @@ around 'eval' => sub {
     foreach my $var (keys %{$lex->get_context('_')}) {
         $var = substr($var, 1); # we drop the variable idiom as it confuses the completion
         $self->push_completion($var) unless 
-            grep /^${var}$/, @{$self->term->Attribs->{completion_word}};
+            grep $_ eq $var, @{$self->term->Attribs->{completion_word}};
     }
 
     return @ret;