From 31a0b05ce77f8375e4a17154ad6bf7742fef5923 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Tue, 25 Nov 2014 14:31:47 -0600 Subject: [PATCH] use Capture::Tiny to get string representation of SEXP Hacky solution to #8 . This will need to be revisited later. --- cpanfile | 1 + lib/R/Sexp.pm | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cpanfile b/cpanfile index fe795dc..242be70 100644 --- a/cpanfile +++ b/cpanfile @@ -1,3 +1,4 @@ requires 'Inline::C'; requires 'PDL'; requires 'Scalar::Util::Numeric'; +requires 'Capture::Tiny'; diff --git a/lib/R/Sexp.pm b/lib/R/Sexp.pm index 1d27190..84b3fb7 100644 --- a/lib/R/Sexp.pm +++ b/lib/R/Sexp.pm @@ -5,12 +5,16 @@ use warnings; use Inline with => qw(R::Inline::Rinline R::Inline::Rpdl R::Inline::Rutil); use Inline 'C'; +use Capture::Tiny qw(capture_stdout); -#use overload '""' => \&string; +use overload '""' => \&string; sub string { my ($self) = @_; - return $self->_string; + my $str = capture_stdout { + $self->_string; + }; + return $str; } 1;