SYNOPSIS
eval("use CGI");
if ($@) { die "Load error"; }
DESCRIPTION
½ºÅ©¸³Æ®ÀÇ È¿À²¹®Á¦·Î ¸ðµâÀ» ¼±ÅÃÇÏ¿© ·ÎµåÇÏ°í ½ÍÀ»¶§ À̸¦ ÇØ°áÇغ¸ÀÚ.
require ¸¦ ÀÌ¿ëÇÑ ¹æ¹ý
require´Â ¶óÀ̺귯¸®°¡ µÉ ÆÄÀÏÀÇ ³»¿ëÀ» ±× À§Ä¡¿¡´Ù°¡ Á÷Á¢½á³Ö´Â C¿¡¼ÀÇ include ¹®°ú °°´Ù°í º¸¸éµÇ°Ú½À´Ï´Ù.
Äڵ带 ·ÎµåÇϱ⺸´Ù´Â »ðÀÔÇÑ´Ù°í »ý°¢ÇÏ½Ã´Â°Ô ´õ °¡±õ½À´Ï´Ù.
## »ðÀÔÀ» ÇÇÇØ°¥¼ö ÀÖ´Ù
if ( 0 ){
require "cgi_lib.pl";
}
## Æ÷ÇÔÇÒ ½ºÅ©¸³Æ®ÀÇ À̸§À» µ¿ÀûÀ¸·Î ÁöÁ¤
$file = "cgi_lib.pl"
require $file;
use ¸¦ ÀÌ¿ëÇÑ ¹æ¹ý
use´Â require¿Í ´Ù¸¥ Ư¼ºÀ» °®´Âµ¥,
ù°, Áߺ¹·ÎµùÀ» ¸·½À´Ï´Ù.
µÑ°, ·ÎÁ÷È帧°ú »ó°ü¾øÀÌ »õ·Î¿î ¿µ¿ª¿¡ ·ÎµùµË´Ï´Ù.
ÄÄÆÄÀϽÿ¡ ¹®¸ÆÀ» µûÁöÁö¾Ê°í ¹ß°ßµÇ´Â use¹®À» ´ÜÇѹø¸¸ ó¸®ÇÏ°Ô µÈ´Ù.
±×·¡¼ require ¿Í °°ÀÌ ¾²·Á°í ÇÑ´Ù¸é
## ÇÇÇÒ¼ö ¾ø´Ù!!
if ( 0 ){
use CGI;
}
## ½ºÄ®¶ó¸¦ Àμö·Î ÁÖ´Â°Ô ¾Æ´Ï´Ù!!
$file = "CGI"
use $file;
## ·çÇÁ¹Û¿¡¼ Çѹø¸¸ ·ÎµåÇÑ´Ù!!
for(1..10){
use DoSomething;
}
ÀÌ·¸°Ô ¾öû³ È¥µ·ÀÌ ¿À°ÔµË´Ï´Ù. use´Â Ç¥Çö½ÄÀÌ ¾Æ´Ï±â ¶§¹®ÀÔ´Ï´Ù.
ÇÏÁö¸¸ use¸¦ ¾²¸é Á»´õ ÀÇÁ¸¼ºÀÌ ÀûÀº ¶óÀ̺귯¸®¸¦ ÀÛ¼ºÇÏ°Ô µÇ´Â À̵æÀ» º¼¼ö°¡ ÀÖ½À´Ï´Ù.
±×·¯³ª use¸¸À¸·Î´Â ¸ðµâÀ» ¼±ÅÃÇÏ¿© ·ÎµåÇÒ¼ö ¾ø½À´Ï´Ù. ¾îµð¿¡ Àû¾îÁֵ簣¿¡ ·ÎµåµÇ¾î¹ö¸®±â ¶§¹®ÀÔ´Ï´Ù.
use·Î requireó·³ ¿øÇÏÁö ¾Ê´Â ¸ðµâÀº ÇÇÇØ°¡´Â ¹æ¹ý...
if ( 0 ) {
eval( "use CGI");
}
¿Í °°ÀÌ ¸¸µé¾îÁÖ¸é µ¿ÀûÀ¸·Î useÇÒ¼ö ÀÖ½À´Ï´Ù. ¹°·Ð ºñ½ÁÇÏ°Ô ¸ðµâ¸íÀ» µ¿ÀûÀ¸·Î ÁöÁ¤ÇØÁÙ¼öµµ ÀÖ½À´Ï´Ù.
$m = "CGI";
eval( "use $m");
µ¿Àû·Îµå ½ÇÆÐÀÇ Ã³¸®
require ´Â µð·ºÅ丮ÀÇ ÆÄÀÏÀ» Á÷Á¢ ÁöÁ¤Çϱ⶧¹®¿¡ ÆÄÀÏÀÇ Á¸À縸 È®ÀÎÇÏ¸é µ¿ÀûÀ¸·Î ·ÎµåÇϱâ Àü¿¡ ½ÇÆи¦ ¸·À»¼ö ÀÖ½À´Ï´Ù.
ÇÏÁö¸¸ use´Â ¸ðµâÀÌ ¼³Ä¡µÈ ÆнºµéÀ» ã¾Æ ·ÎµåÇϱ⶧¹®¿¡ ÀÏÀÏÀÌ Ã£¾ÆÁֱ⵵ Èûµé»Ó´õ·¯ Á¾¼Ó¼º±îÁö ¹Ì¸® üũÇØÁÙ¼ö ¾ø½À´Ï´Ù.
±×·¡¼ µ¿Àû·ÎµåÈÄ¿¡ ó¸®ÇÕ´Ï´Ù.
eval ¹®Àº ½ºÅ©¸³Æ®ÀÇ Ä¡¸íÀûÀÎ ¿¡·¯¸¦ °¨Ãç(catch)ÁÝ´Ï´Ù. ±×¸®°í $@ º¯¼ö¿¡ ±× ¿¡·¯¸¦ ÀúÀåÇÏ°Ô µË´Ï´Ù.
ÀÌ°ÍÀ» ÀÌ¿ëÇؼ
eval("use CGI");
if ($@) { die "Load error"; }
¿Í °°ÀÌ Çϸé CGI¸ðµâÀÌ ¾øÀ»¶§ Load error À» Ãâ·ÂÇÏ°í ½ºÅ©¸³Æ®¸¦ Á¾·áÇÕ´Ï´Ù.
AUTHOR
±èÇö½Â(Kim, hyuns) - sng2nara@hotmail.com
REFERENCE
ÆÞÄھ¼
COPYRIGHT
Copyright 2002, Hyuns Kim. All right reserved.
This is a PMDocs of Perlmania. You may copy or redistribute it under the same terms as Perl itself.
|