1.In clion:
use strict;
use warnings FATAL => 'all';
use Scalar::Util qw(looks_like_number);
my $todlist="GOTO / -71.42857, -16.00000, -49.48717,-0.866025, 0.000000,-0.500000";
my @do = split( /\/|,|\s/, $todlist);
my @str=round_num03(@do);
print(@str);
#foreach my $element (@str) {
# print ($element);
#}
sub round_num03{
foreach (@_) {
if ( looks_like_number($_) )
{
$_ = sprintf( "|%.3f", $_);
}
}
return @_;
}
I get result:GOTO|-71.429|-16.000|-49.487|-0.866|0.000|-0.500
2.In my emaces org mode,
#+BEGIN_SRC perl :results value :exports results both
use strict;
use warnings FATAL => 'all';
use Scalar::Util qw(looks_like_number);
my $todlist="GOTO / -71.42857, -16.00000, -49.48717,-0.866025, 0.000000,-0.500000";
my @do = split( /\/|,|\s/, $todlist);
my @str=round_num03(@do);
#print(@str);
#foreach my $element (@str) {
# print ($element);
#}
return @str;
sub round_num03{
foreach (@_) {
if ( looks_like_number($_) )
{
$_ = sprintf( "|%.3f", $_);
}
}
return @_;
}
#+END_SRC
#+RESULTS:
: 16
The result is 16,may be the size of the array.why? And how to return the string .