#!perl6
use v6;
my $m = 70;
my $n = 30;
( $m div $n ).say;
第一个示例有效,但第二个示例无效。我想这是因为在第二个示例中,变量值是字符串。如果我的猜测是正确的,我怎么能将字符串变量更改为整数变量?
#!perl6
use v6;
my $m = '70';
my $n = '30';
( $m div $n ).say;
# No applicable candidates found to dispatch to for 'infix:<div>'.
# Available candidates are:
# :(Int $a, Int $b)
# in main program body at line 7:./perl5.pl