--- loncom/homework/lonr.pm 2009/08/14 01:58:52 1.9 +++ loncom/homework/lonr.pm 2014/11/19 21:14:47 1.11 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Interface routines to R CAS # -# $Id: lonr.pm,v 1.9 2009/08/14 01:58:52 www Exp $ +# $Id: lonr.pm,v 1.11 2014/11/19 21:14:47 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -33,11 +33,8 @@ use IO::Socket; use Apache::lonnet; use Apache::response(); use LONCAPA; - -### You need to install the libraries below for this to work! - -###use Tie::IxHash::Easy; # autoties all subhashes to keep index order -###use Data::Dumper; # used to output hash contents +use Tie::IxHash::Easy; # autoties all subhashes to keep index order +use Data::Dumper; # used to output hash contents my $errormsg=''; @@ -56,7 +53,9 @@ sub Rcroak { # sub Rpeel { my $x = $_[0]; # the string containing the serialized R object(s) - if ($x =~ /^((?:i|d):(.+?);)(.*)$/) { + if ($x =~ /^N\;(.*)$/) { + return ('',$1); + } elsif ($x =~ /^((?:i|d):(.+?);)(.*)$/) { return ($1, $+); # x starts with a number } elsif ($x =~ /^s:(\d+):/) { my $n = $1; # x starts with a string of length n @@ -150,6 +149,8 @@ sub Rreturn { } if ($errormsg) { return $errormsg; } return \%h; # return a reference to the hash + } elsif ($x eq '') { + return ''; } else { return 'Unrecognized output'; }