[libvirt] [tck PATCH v2 12/13] lib: don't re-assign $_

Daniel P. Berrangé posted 13 patches 6 years, 11 months ago
[libvirt] [tck PATCH v2 12/13] lib: don't re-assign $_
Posted by Daniel P. Berrangé 6 years, 11 months ago
Perl has started to forbid code from declaring "my $_", because $_ is
implicitly always a local scope. Rewrite the code to avoid tickling this
warning.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 lib/Sys/Virt/TCK/Hooks.pm | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/Sys/Virt/TCK/Hooks.pm b/lib/Sys/Virt/TCK/Hooks.pm
index e7a8f76..7d35072 100644
--- a/lib/Sys/Virt/TCK/Hooks.pm
+++ b/lib/Sys/Virt/TCK/Hooks.pm
@@ -71,11 +71,10 @@ sub expect_result {
 sub libvirtd_status {
     my $self = shift;
     my $status = `service libvirtd status`;
-    my $_ = $status;
 
-    if (/stopped|unused|inactive/) {
+    if ($status =~ /stopped|unused|inactive/) {
         $self->{libvirtd_status} = 'stopped';
-    } elsif (/running|active/) {
+    } elsif ($status =~ /running|active/) {
         $self->{libvirtd_status} = 'running';
     }
 
-- 
2.17.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [tck PATCH v2 12/13] lib: don't re-assign $_
Posted by Laine Stump 6 years, 11 months ago
On 05/21/2018 12:46 PM, Daniel P. Berrangé wrote:
> Perl has started to forbid code from declaring "my $_", because $_ is
> implicitly always a local scope. Rewrite the code to avoid tickling this
> warning.
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

Reviewed-by: Laine Stump <laine@laine.org>

> ---
>  lib/Sys/Virt/TCK/Hooks.pm | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/lib/Sys/Virt/TCK/Hooks.pm b/lib/Sys/Virt/TCK/Hooks.pm
> index e7a8f76..7d35072 100644
> --- a/lib/Sys/Virt/TCK/Hooks.pm
> +++ b/lib/Sys/Virt/TCK/Hooks.pm
> @@ -71,11 +71,10 @@ sub expect_result {
>  sub libvirtd_status {
>      my $self = shift;
>      my $status = `service libvirtd status`;
> -    my $_ = $status;
>  
> -    if (/stopped|unused|inactive/) {
> +    if ($status =~ /stopped|unused|inactive/) {
>          $self->{libvirtd_status} = 'stopped';
> -    } elsif (/running|active/) {
> +    } elsif ($status =~ /running|active/) {
>          $self->{libvirtd_status} = 'running';
>      }
>  


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list