use Data::Dumper; sub handle { my($data)=@_; if($data->{change} eq "empty") { print "empty workspace!!\n"; my $switched; $switched = $i3->command("workspace 1")->cb(sub { my( $reply ) = @_; print "Switched back to workspace 1\n"; undef $switched; use Data::Dumper; print Dumper $reply; }); } }