Newsgroups: comp.lang.perl Path: utzoo!utgpu!cunews!bnrgate!bmers145!friedman From: friedman@chekov.UU.NET (Barry Friedman) Subject: defined() - bug or feature? Message-ID: <1991Mar21.142935.11333@bmers145.bnr.ca> Sender: news@bmers145.bnr.ca Reply-To: friedman%chekov@uunet.uu.net Organization: Northern Telecom Ltd. Date: Thu, 21 Mar 91 14:29:35 GMT I've noticed the following non-intuitive behaviour of 'defined()': When a variable is used in a string it becomes defined. I don't recall any discussion on this. #!/usr/bin/perl $a='$b is undefined'; $a='$b is defined' if defined ($b); print $a,"\n"; print "b is now <$b>","\n"; $a='$b is defined' if defined ($b); print $a,"\n"; __END__ produces $b is undefined b is now <> $b is defined -- Barry Friedman INTERNET: friedman%chekov@uunet.uu.net Phone: (613) 782-2389 UUCP: ...!uunet!chekov!friedman Emax Computer Systems Inc. 440 Laurier Ave. W., Ottawa, Ont. Canada K1R 5C4