我是perl的新手,我正在尝试做这个练习,但它不起作用.
这是我创建的模块.
#!/usr/bin/perl
use warnings;
use strict;
package Prepare;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw( clean my_print );
sub clean{
return chomp($_[0]);
}
sub my_print{
return print("The Results: $_[0]\n");
}
1;
Run Code Online (Sandbox Code Playgroud)
这是我的脚本test_lib.pl
#!/usr/bin/perl
use warnings;
use strict;
use lib '/home/foobar/code';
use My::Prepare;
print "Enter a word: ";
my $input=<STDIN>;
print "You entered: $varia";
clean($input);
my_print($input);
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Undefined subroutine &main::clean called at ./test_lib.pl line 13, <STDIN> line 1.
Run Code Online (Sandbox Code Playgroud) perl ×1