问题解决了已经

问题解决了已经

这个问题解决了

还有这个也不对
#!/usr/bin/perl -w
@array= 5..9;
$fred = pop (@array);
$barney = pop @array;
pop @array;
#!/usr/bin/perl -w
@rocks = qw/ bedrock slate lava /;
foreach @rock (@rocks) {
$rock = "\t$rock";
$rock .= "\n";
}
print "the rocks are: \n", @rocks;
#--------------------------------------------------------
[root@localhost perl]# ./test4.pl
syntax error at ./test4.pl line 3, near "foreach @rock "
syntax error at ./test4.pl line 6, near "}"
Execution of ./test4.pl aborted due to compilation errors.

请在任何perl程序里面加入 use strict; use warnings;
你3楼错误,他说明白了,语法错误
foreach $rock(@rocks){...}
#!/usr/bin/perl -w
use strict;
use warnings;
@rocks = qw( bedrock slate lava );
foreach @rock (@rocks)
{
$rock = "\t$rock";
$rock .= "\n";
}
print "the rocks are: \n", @rocks;

#---------------------------------------------------------------------------------

[root@localhost perl]# ./test4.pl
Global symbol "@rocks" requires explicit package name at ./test4.pl line 4.
syntax error at ./test4.pl line 5, near "foreach @rock "
Global symbol "@rock" requires explicit package name at ./test4.pl line 5.
Global symbol "@rocks" requires explicit package name at ./test4.pl line 5.
Global symbol "$rock" requires explicit package name at ./test4.pl line 7.
Global symbol "$rock" requires explicit package name at ./test4.pl line 7.
Global symbol "$rock" requires explicit package name at ./test4.pl line 8.
syntax error at ./test4.pl line 9, near "}"
Execution of ./test4.pl aborted due to compilation errors.

那不就更明白了,别乱用全局变量
请在你要使用的变量前面加my作为声明
让人帮助解释那些语法错误?
楼主怎么还删帖了。。。。
我刚学照书打的居然出错,就上来问问,第一帖问题现在解决了,目前是第三帖有问题,
但是谢谢以上几为指教