My code:
#!/usr/bin/perl
use strict;
use warnings;
thesub("hello");
sub thesub {
my $class = shift;
my $self = shift;
return $self;
}
my $testvar = thesub();
print $testvar;
$testvar print nothing, I want to print hello.
I have intent to change thesub() to &thesub, but not work.
I read that In Perl, scalar variables cannot hold subroutines directly.
How can I fixed this case ?
Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…