PowerPoint プレゼンテーション

Save this PDF as:
 WORD  PNG  TXT  JPG

Size: px
Start display at page:

Download "PowerPoint プレゼンテーション"

Transcription

1 Perl CGI 1

2 Perl CGI 2

3 Perl CGI 3

4 Perl CGI 4

5 1. <html> 2. <head> 1. #!/usr/local/bin/perl 2. print "Content-type: text/html n n"; 3. print "<html> n"; 4. print "<head> n"; 3. <title> </title> 4. </head> 5. print "<title> 5. <body> </title> n"; 6. hello, world. 6. print "</head> n"; 7. </body> 7. print "<body> n"; 8. </html> 8. print "hello, world. n"; 9. print "</body> n"; 10.print "</html> n"; Perl CGI 5

6 _ Perl CGI 6

7 PC Perl CGI 7

8 Perl CGI 8

9 Perl CGI 9

10 Perl CGI 10

11 Perl CGI 11

12 (Perl) Web Perl CGI 12

13 Perl CGI 13

14 Perl CGI 14

15 print print < > < > print abcd ; abcd print abcd n ; abcd print abcd. efg n ; abcdefg $var= hij ; print abcd.$var. n ; abcdhij Perl CGI 15

16 print ; xxx print ; Unix Perl CGI 16

17 1. $a=50; 1. $a= aa ; 2. $b=65; 2. $b= bb ; 3. $c=$a+$b; 3. $arr[ ] 1. $a[0]=50; 1. $a[0]= aa ; 2. $a[1]=65; 2. $a[1]= bb ; 3. $a[2]=$a[0]+$a[1]; 3. $a[2]=$a.$b; Perl CGI 17

18 %hash $hash{ } 1. $a{ apple }=50; 2. $a{ orange }=65; 3. $a{ sum }=$a{ apple }+$a{ orange }; 1. $a{ apple }= red ; 2. $a{ orange }= orange ; 3. $a{ color }=$a{ apple }.$a{ orange }; Perl CGI 18

19 print "hello,".".$form{yourname}"."<br> n"; %FORM Perl CGI 19

20 Perl CGI 20

21 1. print "<body> n"; 2. print "<form action=clsboard.cgi method=post> n"; 3. print "<h1> </h1> n"; 4. print "<h2> </h2> n"; 5. print "<input type= "text ", name= "yourname " value=".$form{yourname}.""."><br> n"; 6. print "<h2> </h2> n"; 7. print <textarea name= yourcomment rows=5 cols=30> n.$form{yourcomment}. "." n</textarea><br> n"; 8. print "<input type= "submit " value= " "> n"; 9. print "</form> n"; 10.print "</body> n"; Perl CGI 21

22 Perl CGI 22

23 Perl CGI 23

24 Perl CGI 24 open(db, close(db); print $data[0]; print $data[1]; print $data[2]; [ ] [ ] [ ]

25 open(db, >opinion") print DB ; print DB ; print DB ; close(db); Open(DB, >>opinion ); Perl CGI 25

26 chop($data[0]);, [ ], $data[0], ($name,$comment)=split(/,/,$data[0]); $name $comment Perl CGI 26

27 Perl CGI 27

28 touch clsboard.txt # chmod a+w clsboard.txt# Perl CGI 28

29 1. $datafile="clsboard.txt"; 2. open(db,"$datafile"); 4. close(db); 5. print "<table border=1> n"; 6. print "<tr><td> </td><td> </td></tr> n"; 7. chop($data[0]); 8. ($namae,$iken)=split(/,/,$data[0]); 9. print "<tr><td>".$namae."</td><td>".$iken."</td></tr> n"; 10. chop($data[1]); 11. ($namae,$iken)=split(/,/,$data[1]); 12. print "<tr><td>".$namae."</td><td>".$iken."</td></tr> n"; 13. print "<tr><td>".$form{yourname}."</td><td>".$form{yourcomment}." </td></tr> n"; 14. print "</table> n"; 15. open(db,">$datafile"); 16. print DB $data[1]." n"; 17. print DB $FORM{yourName}.",".$FORM{yourComment}." n"; 18. close(db); Perl CGI 29

30 1. open(db, opinion") 3. close(db); 4. print $data[0]; 5. print $data[1]; 6. print $data[2]; 1. chop($data[0]); 2. ($namae,$iken)=split(/,/, $data[0]); 3. print "<tr><td>".$namae."</td>< td>".$iken."</td></tr> n"; 4. chop($data[1]); 5. ($namae,$iken)=split(/,/, $data[1]); 6. print "<tr><td>".$namae."</td>< td>".$iken."</td></tr> n"; Perl CGI 30

31 Perl CGI 31

32 if if( ){ }else{ } 9. a 1. if ($a==0){ b=1 2. $b=1; 3. }else{ a 4. $b=2; b=2 5. } Perl CGI 32

33 $a=5;$b=7; == eq $a!= $b!= ne $a >= $b < lt > gt $a= abc ;$b= cde ;$c=abc <= le $a eq $c $a ge $b >= ge $r=open(db, file ); $r $r 1. $r=open(db, opinion") 2. if($r){ 4. close(db); 5. print $data[0]; 6. print $data[1]; 1. if(open(db, opinion")){ 7. } Perl CGI 33

34 while 1. while( ){ } $a=3 $b=0 $a=1 $b=4 1. $a=3;$b=0; $a=3 $b=0 $a=1 $b=6 2. while($a>0){ $a=3 $b=2 $a=0 $b=6 3. $b=$b+2; $a=2 $b=2 $a=0 $b=6 4. $a=$a-1; $a=2 $b=2 $a=0 $b=6 5. } $a=2 $b=4 $a=1 $b=4 yes Perl CGI 34 no

35 foreach 1. foreach $i( ){ 2. $i } $s= $i r, g, b ) 2. $s= ; 3. foreach $i 4. $s=$s.$i; 5. } $i= r $s= $i= r $s= r $i= g $s= r $i= g $s= rg $i= b $s= rg $i= b $s= rgb Perl CGI 35

36 Perl CGI 36

37 Perl CGI 37

38 Perl CGI

39 Perl CGI 39

40 Perl CGI 40

41 Perl CGI 41

42 Perl CGI 42