Permalink
Browse files

Using reftype to check for a hashref is much more robust

  • Loading branch information...
1 parent 66ad069 commit 370d5ae6463d94e5e950175fe3b884e5de9a14cb @hercynium committed Oct 2, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/AnyEvent/Open3/Simple.pm
View
3 lib/AnyEvent/Open3/Simple.pm
@@ -5,6 +5,7 @@ use warnings;
use v5.10;
use AnyEvent;
use IPC::Open3 qw( open3 );
+use Scalar::Util qw( reftype );
use Symbol qw( gensym );
use AnyEvent::Open3::Simple::Process;
@@ -109,7 +110,7 @@ sub new
{
state $default_handler = sub { };
my $class = shift;
- my $args = ref $_[0] eq 'HASH' ? shift : { @_ };
+ my $args = reftype($_[0]) eq 'HASH' ? shift : { @_ };
my %self;
$self{$_} = $args->{$_} // $default_handler for qw( on_stdout on_stderr on_start on_exit on_signal on_fail on_error );
bless \%self, $class;

0 comments on commit 370d5ae

Please sign in to comment.