1 #!/usr/bin/perl 2 3 use strict; 4 use warnings; 5 6 $_ = 'duwanxkm,c.,df;oq123@#!@%$#^'; 7 my $d ='d';my $o = 'o';my $where =index($_,$o);print "$where "; 8 $where =index($_,$d,7);print "$where "; 9 $where =index($_,'y');print "$where "; 10 my $lastword = rindex("%23%4546","%",2);print "$lastword "; 11 12 #15 13 #12 14 #-1 15 #3 16 #0 17 18 my $sentence = 'very very long'; 19 my $cut = substr ($sentence,index($sentence,'long'),3);substr ($sentence,index($sentence,'long'),3)='yoo!';print "$sentence $cut "; 20 substr ($sentence,-12) =~ s/o/AAAAAA/g;print "$sentence "; 21 22 #very very yoo!g 23 #lon 24 #very very yAAAAAAAAAAAA!g 25 26 my $new = substr ($sentence,3,10,"GOOOOO");print "$new $sentence "; 27 28 #y very yAA 29 #verGOOOOOAAAAAAAAAA!g