Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2863051
  • 博文数量: 178
  • 博客积分: 2076
  • 博客等级: 大尉
  • 技术积分: 2800
  • 用 户 组: 普通用户
  • 注册时间: 2008-01-10 10:50
文章分类

全部博文(178)

文章存档

2010年(4)

2009年(13)

2008年(161)

我的朋友

分类: LINUX

2008-09-10 17:43:17

#!/usr/bin/perl -w
#list give values
@rock1=qw( mylove cry );
@rock=qw/ this is love /;
($w1,$w2)=qw(w1 w2);
print "this is \$rock[1]:".$rock[1]."\n";
print "this is \$rock1[1]:".$rock1[1]."\n";
print "$w1\n$w2\n";


#args intract
@rock2=qw{ /usr/local/bin /usr/bin /bin };
@rock3=(@rock2, "/var");

print "this is  rock3+++++++++++++++++++\n";
print " $rock3[0] must be /usr/local/bin \n";


print "rock3 last arg\n";
print "$rock3[$#rock3]\n";

@array1=(1..10);
print "the last args array is :\n";
print $array1[$#array1]."\n";

print "pop : give up the last args and return else args\n";
print "if pop(\@array1) methods \n";

pop(@array1);
print $array1[$#array1]."\n";
print "\n\npush(\@ay,value)like push(\@array1,12) ,append the last args\n";

push (@array1,12);
print $array1[$#array1]."\n";
push (@array1,@rock1);
print $array1[$#array1]."\n";
push (@array1,3..8);
print $array1[$#array1]."\n";


#shift and unshift

$shiftreturnresult=shift(@array1); #now shiftreturnresult is 1;
print "shift and unshift operation\n";
print "$shiftreturnresult\n";

unshift(@array1,5);
print $#array1."\n";

@array2=qw(xiao is love yuang now );
print "@array2\n";
print " I am xiao ,@array2\n";

#practise for foreach


@array3=(1..10);#qw(1..10) this is format as 1..10 ,something format string means....
foreach $arr(@array3)
  {
         $arr="\t$arr\n";
         print $arr
  }
print "@array3\n";

foreach $arr(qw{1 2 3 4}){

       print "arraynum is $arr \.\n";
 }



#perl default bianliang
print "default ***** \$\_\n";
  foreach(qw(1 2 3 4 5)){
    print "$_\t";
 }
print "\n";
  $_="abced edfdf\n";
print $_;

print "reverse\n";

@rry=(1..10);
@rry1=qw/ yes or no /;
@fred=reverse @rry; ##reverse could not change rry values just return whatis happen;
#pop(@rry); can change rry,very importance G
print "@fred"."\n";
@fred1=reverse @rry1;
print "@fred1\n";
print "sort \n";
@srotd=sort (@rry1);
print "srotd @srotd\n";
@re=reverse @srotd;
print "@re\n";
print "Enter some lines, then press Ctrl-D:\n"; # or maybe Ctrl-Z
    @lines = ;
    @reverse_lines = reverse @lines;
    print @reverse_lines;
 
 
 
 
vi perl003.pl            
   my($m,$n)=@_;
 return open $m,$n;
}
@seq=reverse(0..$#ARGV);
sub rev{
    my(@n)=reverse(@_);
     foreach(@n){
     print "$_";
 }

}
foreach(@seq)
  {
      $eq="F$_";
     $Y=open("F$_","$ARGV[$_]");
     #  while(<$eq>)
      #{
    #     print $_;
     #}
 @SE=<$eq>;
#print @SE;
@SE=reverse(@SE);
 foreach(@SE)
 {
        print $_;
 }
}
阅读(357) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~