perl的helloworld

http://zhidao.baidu.com/question/177283266.html
http://www.vim.org/scripts/script.php?script_id=556

apple:Desktop apple$ cat test.pl
#!/usr/bin/perl
use strict;
use warnings;
print "Hello,
world\n";
print
"Hello,world\n"
;

my $animal = "camel";
my $answer = 42;
print "The animal is $animal\n";
print "The square of $answer is ", $answer * $answer, "\n";
print;

my @animals = ("camel", "llama", "owl");
my @numbers = (23, 42, 69);
my @mixed = ("camel", 42, 1.23);

print $mixed[$#mixed];
print "\n";
print @animals[0,1]; # gives ("camel", "llama");
print "\n";
print @animals[0..2]; # gives ("camel", "llama", "owl");
print "\n";
print @animals[1..$#animals]; # gives all except the first element
print "\n";

print "sort---\n";
my @sorted = sort @animals;
print @sorted[0..$#sorted];
#my @backwards = reverse @numbers;
#print @backwords[0..$#backwords];
apple:Desktop apple$


cp *.zip ~/.vim/
unzip *.zip
vim下:helptags ~/.vim/doc
否则help不好使
:h perlsupport

破玩意,没用明白。破帮助,装完之后vim *.pl竟然报错
这个说得好像很有道理,但是国内好像被墙了,郁闷了
http://blog.csdn.net/cityeremite/archive/2009/09/08/4533547.aspx

ftp://mirrors.sohu.com/CPAN/

-----------------cat----
#!/usr/bin/perl
while($line=<>){
print ($line);
}

--------------
#!/usr/bin/perl 
if(!-e "/root/Desktop/perl/test"){
print STDERR ("file test is not exists.");
}else{
if(open(MYFILE,"/root/Desktop/perl/test")){
$line=<MYFILE>;
@array= <MYFILE>;
print $line;
print @array;
}
}

-------------------my local our *-------------
#!/usr/bin/perl
&testsub;
sub testsub{
print "this is a sub named 'testsub'\n\n";
}

@testarray=("aa","bb","cc");
&sub1(@testarray);
sub sub1{
my(@list) = @_;
print @list,"\n";
@list=("b","k");
print @list,"\n";
}
print @testarray,"\n\n";

$foo=26;
&testsub1(*foo);
sub testsub1{
local(*printarray)=@_;
print $printarray,"\n";
$printarray=61;
}
print $foo,"\n\n";
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值