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