Permalink
Browse files

Using scalar grep rather than tilde tilde

  • Loading branch information...
1 parent d674a6f commit 3f67f1547736b631141940ffcee753d75141b5e9 @mfontani committed Jan 14, 2011
Showing with 8 additions and 6 deletions.
  1. +6 −5 lib/Net/RackSpace/CloudServers.pm
  2. +2 −1 lib/Net/RackSpace/CloudServers/Limits.pm
@@ -163,8 +163,8 @@ sub get_server {
[ 'X-Auth-Token' => $self->token ]
);
my $response = $self->_request($request);
- return if $response->code ~~ [ 204, 404 ];
- confess 'Unknown error' . $response->code unless ( $response->code ~~ [ 200, 203 ] );
+ return if scalar grep { $response->code eq $_ } (204, 404);
+ confess 'Unknown error' . $response->code unless scalar grep { $response->code eq $_ } (200, 203);
my @servers;
my $hash_response = from_json( $response->content );
warn Dump($hash_response) if $DEBUG;
@@ -237,7 +237,8 @@ sub get_flavor {
);
my $response = $self->_request($request);
return if $response->code == 204;
- confess 'Unknown error ' . $response->code unless ( $response->code ~~ [ 200, 203 ] );
+ confess 'Unknown error ' . $response->code
+ unless scalar grep { $response->code eq $_ } ( 200, 203 );
my $hash_response = from_json( $response->content );
warn Dump($hash_response) if $DEBUG;
@@ -291,7 +292,7 @@ sub get_image {
);
my $response = $self->_request($request);
return if $response->code == 204;
- confess 'Unknown error ' . $response->code unless ( $response->code ~~ [ 200, 203 ] );
+ confess 'Unknown error' . $response->code unless scalar grep { $response->code eq $_ } (200, 203);
my $hash_response = from_json( $response->content );
warn Dump($hash_response) if $DEBUG;
@@ -346,7 +347,7 @@ sub delete_image {
],
);
my $response = $self->_request($request);
- confess 'Unknown error ' . $response->code unless ( $response->code ~~ [ 202, 204 ] );
+ confess 'Unknown error' . $response->code unless scalar grep { $response->code eq $_ } (200, 204);
return;
}
@@ -31,7 +31,8 @@ sub refresh {
);
my $response = $self->cloudservers->_request($request);
return if $response->code == 204;
- confess 'Unknown error ' . $response->code unless ( $response->code ~~ [ 200, 203 ] );
+ confess 'Unknown error ' . $response->code
+ unless scalar grep { $response->code eq $_ } (200, 203);
my $hr = from_json( $response->content );
warn Dump($hr) if $DEBUG;

0 comments on commit 3f67f15

Please sign in to comment.