dev/perl/study0.pl

112 lines
2.5 KiB
Perl
Raw Normal View History

#!/usr/bin/perl
# print "X p |-o -- x P I-O, world!\n"
#$NAMe = 'Johnny';
#$AGe=33;
#@BOOK=('Introduction', 'First Chapter', 'Second Chapter');
#%StaR_waRs_family=('faTher','Anakin','Mother','Padme','Male twin','Luke','Female twin','Leina');
#print $StaR_waRs_family{'faTher'};
#print "\n";
#$res=`ls /usr/bin`;
#print $res
#$a='Hello';
#$b='$a, world!';
#$c="$a, world!";
#print $b,"\n";
#print $c,"\n";
#%StarWarsFamily=(
# 'Father',{'Name','Anikin',
# 'Height(cm)',210,
# 'jobs',{'Slave','Podracer pilot','Jedi Knight','Darth Vader'}},
# 'Mother',{} # другие такие же данные...
#);
#print "$StarWarsFamily{'Father'}{'jobs'}{'Slave'}\n";
#print `date`
#$A=10*7.5-16;
#$b=$A%4;
#print "A = ",$A,"\nB = ",$b,"\n";
#$A++;
#$b-=9;
#print "A = ",$A,"\nB = ",$b,"\n";
#$s="act&";
#$s++;
#print $s,"\n";
#$a="Luke"; $b="Skywalker";
#$c=$a." ".$b;
#print "$c " x 3,"\n";
#$a=2; $b=3;
#print $a cmp $b;
#if('dude' lt 'hello') {print "dude";}
#if('dude' < 'hello') {print "hello";}
#@Jedi=("Yoda","Obi Wan");
#push(@Jedi,"Anakin");
#print $Jedi[2]."\n";
#pop(@Jedi);
#print $Jedi[2]."\n";
#%days=('January',31,'February',28.25,'Mart',31,'April',30,
# 'May',31,'June',30,'July',31,'August',31,'September',30,'October',31,
# 'November',30,'December',31);
#while (($a,$b)=each %days) {print $a,": ",$b,"\n";}
#@A=keys (%days);
#print $A[1]."\n";
#($x,$y,$z)=($y,$z,$x);
#($Name,$Surname,$Address)=('Kolan','Shashkin','Bratskaya,5a');
#($var,$arr)=('Переменная','m1','m2','m3');
#@a=(0,1,2,3);
#for($i=0;$i<7;$i++) {print $a[$i]."\n";}
#splice(@a,2,0,('a','b'));
#for($i=0;$i<7;$i++) {print $a[$i]."\n";}
#@a=(34,2,553,2,15);
#@a=sort (@a); #@a=sort AS_I_WANT (@a);
#for($i=0;$i<10;$i++){print $a[$i]."\n";}
#@a = <STDIN>;
#for($i=0;$i<10;$i++){print $a[$i];}
#%hash=('a','b','c','d');
#print $hash{'c'}."\n";
#delete($hash{'c'});
#print $hash{'c'}."\n";
#%a=('a','1','b',$_,'c','3');
#if (defined $a{'b'}) {print "defined ;)\n";}
#else {print "undefined ;(\n";}
#print $a{'b'}."\n";
# Вопрос: Что будет без m в выражении m/hello/
#$string=<STDIN>;
#if($string =~ m/^hello$/) {print "Yes\n";} else {print "No\n";}
#$string =~ s/a/A/g; # g указывает на глобальное изменение
#print $string."\n";
#$jedi='Anakin';
#$jedi=~s/Master $jedi/t he future Darth Vader/g;
#s/Master (Obi-Wan|Yoda)/t he Jedi Knight $1/;
#print $jedi."\n";
$s='Hello, world! My name is hello!';
$s =~ s/(Hello|hello)/ghm $1/g;
print $s."\n";