undefé¢æ° - æªå®ç¾©å¤
undefé¢æ°ã使ãã°ãæªå®ç¾©å¤ãè¨å®ãããã¨ãã§ãã¾ãããããã¯ãå¼æ°ã«æå®ããå¤æ°ã®å¤ãæªå®ç¾©ã«ãã¾ãã
undef undef(å¤æ°)
æªå®ç¾©å¤ã®è¨å®ã¯æ¬¡ã®ããã«è¡ãã¾ããå¤æ°ã$nameãã®å¤ãæªå®ç¾©ã«ãªãã¾ãã
$name = "Kimoto"; $name = undef;
ã¾ã次ã®ããã«undefé¢æ°ã®å¼æ°ã«å¤æ°ã渡ãã¦ããå¤æ°ã®å¤ãæªå®ç¾©ã«ãããã¨ãã§ãã¾ãã
$name = "Kimoto"; undef $name;
é åãããã·ã¥ã«ã¤ãã¦ãundefé¢æ°ãå©ç¨ãããã¨ãã§ãã¾ãã
@names = undef; undef @names; %scores = undef; undef %score;
æªå®ç¾©å¤ã®å¤å®
æªå®ç¾©å¤ãã©ãããå¤å®ããããã«ã¯defined関数ã使ç¨ãããã¨ãã§ãã¾ããå®ç¾©ããã¦ããå ´åã¯çããæªå®ç¾©ã®å ´åã¯å½ãè¿ãã¾ãã
if (defined $name) { ... }
å¤ãæªå®ç¾©ã ã£ãå ´åãå¦çããã®ã«unlessã使ã£ã¦æ¸ãæ¹æ³ããå§ãã§ãã
unless (defined $name) { # æªå®ç¾©ã ã£ãå ´åã®å¦ç }
æªå®ç¾©å¤ã¨ã®æ¯è¼
undefã¯æååã¨ãã¦æ¯è¼ãããå ´åã¯ã空æåãã¨ãã¦ãæ°å¤ã¨ãã¦æ¯è¼ãããå ´åã¯ã0ãã¨ãã¦æ±ããã¾ãã
undef == 0 undef eq ""
warningsモジュールã使ãã°ããã®ãããªå ´åã«è¦åãçºãã¦ããã¦ãæªç¶ã«ãã°ãé²ããã®ã§ãå¿ ã宣è¨ããããã«ãã¾ãããã
use warnings;
undefã使ã£ãã¡ã¢ãªè§£æ¾
undefãä»£å ¥ããã°ã¡ã¢ãªã¯è§£æ¾ããã¾ãã
ããã©ããPerlã§ã¯ãã¬ãã·ã«ã«å¤æ°ã使ãã°ãã¹ã³ã¼ãã®çµããã§èªåçã«ã¡ã¢ãªè§£æ¾ãè¡ãããã®ã§ãã¡ã¢ãªè§£æ¾ã®ããã«undefã使ãæ©ä¼ã¯ã¾ããªãã§ãããã
{ my $num = 5; } # ã¹ã³ã¼ãã®çµããã§ã$numãã®ã¡ã¢ãªã¯è§£æ¾ããã
ãã ããã¹ã³ã¼ããçµãã£ã¦ããã¯ãã¼ã¸ã£ã¼ã®å ´åãªã©ã§ãã¡ã¢ãªã解æ¾ãããªãå ´åãããã¾ãããã®ãããªå ´åã«ã¯ãæ示çã«undefã使ã£ã¦ã¡ã¢ãªè§£æ¾ãè¡ããã¨ãã§ãã¾ãã
ã¯ãã¼ã¸ã£ã«ã¤ãã¦ã¯ä»¥ä¸ã®è¨äºãåèã«ãã¦ãã ããã