¾È³çÇϼ¼¿ä, HappyCGI ÆÀÀÇ voposÀÔ´Ï´Ù.
>¾È³çÇϼ¼¿ä.
>¾Æ·¡ Äڵ尡 ¹«½¼¶æÀÎÁö ¿µ ÀÌÇØ°¡ ¾È°¡´Â ºÎºÐÀÌ ¿©·¯°³ À־ä.. .
>±¸ÂúÀ¸½Ã´õ¶óµµ °¡¸£ÃÄ ÁÖ¼ÌÀ¸¸é °¨»çÇÏ°Ú½À´Ï´Ù.
>
>[1] s///¿¡¼ °¡¿îµ¥ ºÎºÐ "cM"°ú "
>+"°¡ ¹» ÀǹÌÇϴ°ÇÁö ¸ð¸£°Ú¾î¿ä.
>
>$FORM{
comments
} =~ s/cM//g;
>$FORM{
comments
} =~ s/
+/ /g;
cMÀº µµ½º/À©µµ¿ìÁî¿¡¼ »ý¼ºµÇ´Â °³Ç๮ÀÚ(newline character) ÄÚµåÀä, ±×³ð
À» Á¦°ÅÇÏ´Â °ÍÀÔ´Ï´Ù.
"+" °°Àº Ư¼ö¹®ÀÚ¸¦ "meta-character"¶ó°í ¾ê±â¸¦ ÇÏ´Â °Í °°Àºµ¥ Àǹ̴ "+"¾Õ¿¡
³ª¿À´Â ¹®ÀÚ¸¦ Æ÷ÇÔÇؼ Çϳª¶Ç´Â ÇϳªÀÌ»óÀÇ ¹®ÀÚ¸¦ ÀǹÌÇÕ´Ï´Ù. "
" "
"
"
" µîÀÌ ¸ÅÄ¡µÇ°Ú½À´Ï´Ù.
>[2] °¡Àå¾Æ·§ºÎºÐ "$value =~ s///g;"°¡ ¾Æ¸¶µµ Á¦°¡ º¸±â¿¡´Â htmlÄڵ带 Á¦°ÅÁÖ´Â ¿ªÇÒÀ» ÇÏ´Â°Í °°Àºµ¥ ÀÌ°ÍÀÌ Á¤È®È÷ ¾î¶»°Ô Çؼ Á¦°ÅÇØ Áִ°ÇÁö ¸ð¸£°Ú¾î¿ä.
>
>$value =~ tr/+/ /;
>$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>$value =~ s///g;
>
>[3] s///¿¡¼ °¡¿îµ¥ ºÎºÐÀÎ "^s+"°ú "s+$"ÀÌ ÀÌÇØ°¡ ¾È°¡¿ä
>$list=~ s/^s+//;
>$list=~ s/s+$//;
Á¤È®È÷ ¾Ë°í ½ÍÀ¸½Ã¸é Á¤±ÔÇ¥Çö½Ä(regular expression)¿¡ ´ëÇØ °øºÎÇغ¸¼¼¿ä.
http://www.happycgi.com/forum/forum_detail.cgi?thread=6141r02&category=À¥ÇÁ·Î±×·¥_°ü·Ã/PHP_°ü·Ã/PHP_Áú¹®°ú_´äº¯
>[4] ¸¶Áö¸· if¹®¿¡ ´ëÇؼ ÄÚ¸ÇÆ®¸¦ ºÎŹÇÕ´Ï´Ù. ÀÌ°ÍÀº À¯¸íÇÑ way-boardÀÇ µ¥ÀÌÅÍ ÆÛ½Ì ·çƾÀε¥ if¹® Á¶°ÇÀ¸·Î ¾²ÀÎ "defined($Field{$name})"ÀÌ ¹ºÁö ÀÌÇØ°¡ ¾È°©´Ï´Ù. define()ÇÔ¼ö°¡ ¾²Àεí Çѵ¥ ÀÌ·± ÇÔ¼öÀÇ ¾²ÀÓ»õ¸¦ ã¾Æº¼·Á¸é ¾îÂîÇØ¾ß Çϳª¿ä?
defined function¿¡ ´ëÇÑ ¼³¸íÀ» Àо¼¼¿ä.
http://www.perl.com/pub/doc/manual/html/pod/perlfunc/defined.html
>sub input_data {
>
>if ($ENV{
REQUEST_METHOD
} eq
GET
) {
>@pairs = split(/&/, $ENV{
QUERY_STRING
});
>}
>elsif ($ENV{
REQUEST_METHOD
} eq
POST
) {
>read(STDIN, $buffer, $ENV{
CONTENT_LENGTH
});
>@pairs = split(/&/, $buffer);
>}
>else {
>exit;
>}
>
>foreach $pair (@pairs) {
>
>local($name, $value) = split(/=/, $pair);
>
>$name =~ tr/+/ /;
>$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>
>
>$value =~ tr/+/ /;
>$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>$value =~ s///g;
>
>if (defined($Field{$name})) {
>$Field{$name} = $value;
>}
>else {
>if ($Field{$name} && $value) {
>$Field{$name} = "$Field{$name}, $value";
>}
>elsif ($value) {
>$Field{$name} = $value;
>}
>}
>}
>
>}
>
>
>ÈÞ¿ì~~~ ÀÌ»óÀÔ´Ï´Ù. ¾Æ¸¶µµ ±²ÀåÈ÷ Ãʺ¸ÀûÀÎ Áú¹®Àε¥ ÀúÀÇ ¸¶À½Àº Áö±Ý ÄÚ³¢¸® ´Ù¸® ¸¸Áö´Â ±âºÐÀÔ´Ï´Ù.±ÍÂúÀ¸½Ã°ÚÁö¸¸ Á¶±Ý¸¸ µµ¿ÍÁֽŴٸé Àú¿¡°Ô´Â Á¤¸» ¸¹Àº µµ¿òÀÌ µÇ°Ú½À´Ï´Ù.
>°¨»çÇÕ´Ï´Ù.
ÇØÇÇ CGI¿Í ÇÔ²² ÇູÇÑ ½Ã°£ µÇ±æ ¹Ù¶ø´Ï´Ù. °¨»çÇÕ´Ï´Ù.
- vopos
|