zoukankan      html  css  js  c++  java
  • unless|until|LABEL|{}|last|next|redo| || |//|i++|++i

      1 #!/usr/bin/perl
      2 
      3 use strict;
      4 use warnings;
      5 
      6 $_ = 'oireqo````';
      7 
      8 unless($_ =~ /^a/m){print "no match to a
    "}
      9 
     10 #no match to a
     11 
     12 if(!($_ =~ /^a/m)){print "no match to a
    "}
     13 
     14 #no match to a
     15 
     16 unless($_ =~ /^o/m){print "no match to a"}else{print "match!
    "}
     17 
     18 my $number = 1;
     19 
     20 while($number<12)
     21 {
     22     $number++;print "$number
    ";
     23 }
     24 
     25 #2
     26 #3
     27 #4
     28 #5
     29 #6
     30 #7
     31 #8
     32 #9
     33 #10
     34 #11
     35 #12
     36 
     37 until($number<2)
     38 {
     39     $number--;print "$number
    "
     40 }
     41 
     42 #11
     43 #10
     44 #9
     45 #8
     46 #7
     47 #6
     48 #5
     49 #4
     50 #3
     51 #2
     52 #1
     53 
     54 print "match!
    "if($_ =~ /^o/m);
     55 
     56 #match!
     57 
     58 my @arr=(1,2,3,4,5,6,7);print foreach(@arr);print"
    ";
     59 
     60 #1234567
     61 
     62 #my @arr_1=(1,2,3,4,5,6,7);print"$k" foreach my $k($#arr_1);print"
    ";
     63 #Global symbol "$k" requires explicit package name (did you forget to declare "my $k"?) at t.pl line 62.
     64 #syntax error at t.pl line 62, near "$k("
     65 #Execution of t.pl aborted due to compilation errors.
     66 
     67 {
     68     my $k = "good";
     69 }
     70 #print "$k
    ";
     71 
     72 #Global symbol "$k" requires explicit package name (did you forget to declare "my $k"?) at t.pl line 70.
     73 #Execution of t.pl aborted due to compilation errors.
     74 
     75 my @fruit = ('apple','banana','peach','apple','apple');my %match;$match{$_}++ foreach(@fruit);print "$match{$_}
    "foreach(keys %match);
     76 
     77 #1
     78 #1
     79 #3
     80 
     81 my $five_1= 5;my $six_1 = $five_1++;print "$six_1	$five_1
    ";
     82 my $five_2= 5;my $six_2 = ++$five_2;print "$six_2	$five_2
    ";
     83 
     84 #5       6
     85 #6       6
     86 
     87 my %seen;foreach(@fruit) {print "i 've get $_!
    " if $seen{$_}++;}
     88 
     89 #i 've get apple!
     90 #i 've get apple!
     91 
     92 for($_ = "abcdefg";s/(.)//;){print "$1
    ";if($1 eq "f"){last;}}
     93 
     94 #a
     95 #b
     96 #c
     97 #d
     98 #e
     99 #f
    100 my %seen;
    101 
    102 READ:while(<>)
    103 {
    104     foreach(split)
    105     {
    106         next READ if /W/;$seen{$_}++;
    107     }
    108 }
    109 
    110 foreach (keys %seen){print "last:$_ is $seen{$_}
    ";last if /dewm/;}
    111 foreach (keys %seen){print "next:$_ is $seen{$_}
    ";next if /dewm/;}
    112 #foreach (keys %seen){print "redo:$_ is $seen{$_}
    ";redo if /dewm/;}
    113 
    114 # cat 1.txt
    115 # shsjsk   123
    116 # dewm
    117 # shsjsk   123
    118 #  shsjsk   123
    119 #  shsjsk   123
    120 # cat 1.txt |perl t.pl
    121 #last:shsjsk is 4
    122 #next:shsjsk is 4
    123 #next:123 is 4
    124 #next:dewm is 1
    125 #redo:dewm is 1
    126 #……
    127 
    128 my $zero = 0;my $one = 1;
    129 if (($zero != 0)&&($one%$zero==2)){print "get!
    "}
    130 
    131 #
    132 
    133 my %zoo;$zoo{'fish'}='cat',$zoo{'mouse'} ='dog';$zoo{'dog'}="";
    134 my $animal=$zoo{'dog'}||'nobody';print "$animal
    "; 
    135 my $animal_1=$zoo{'panda'}||'nobody';print "$animal_1
    ";
    136 my $animal_2=defined $zoo{'dog'}? '1':'nobody';print "$animal_2
    "; 
    137 my $animal_3=$zoo{'dog'}//'nobody';print "$animal_3
    "; 
    138 
    139 #nobody
    140 #nobody
    141 #1
    142 #
    143 
    144 printf "%s
    ",$animal_3//'nobody';
    145 
    146 #
    147 
    148 my $m =12;($m>20)||print "$m
    ";
    149 
    150 #12
    151 
    152 $m>20 or die "wrong judgement";
    153 
    154 #wrong judgement at t.pl line 152, <> line 5.
  • 相关阅读:
    MAVEN 安装与配置
    MAVEN 常用仓库地址
    一些常用的工具
    springFramework 源码学习之源码下载与编译
    测试工程师学习笔记
    什么是多态
    聚簇索引与非聚簇索引
    正则表达式菜鸟教程
    我的第一篇博客
    转Hibernate继承
  • 原文地址:https://www.cnblogs.com/yuanjingnan/p/11110348.html
Copyright © 2011-2022 走看看