In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Edward WIJAYA) writes: >On Fri, 10 Dec 2004 09:48:26 -0500, Felix Li <[EMAIL PROTECTED]> >wrote: > >> Is there "a one liner" that performs the equivalent of >> sub ReturnAndClear { >> my $temp=$_[0]; >> $_[0]=undef; >> return $temp; >> }; > >Why would you need that? >While you just can simply use like: $val = undef; >in the code?
I assume that the poster is looking for a single expression that will undef a variable while assigning its value to another variable. Okay: % perl -le '$x=42; print "Before: \$x = $x"; \ undef($x = $y = $x); \ print "After: \$y = $y, \$x = ", ($x || "undef")' Before: $x = 42 After: $y = 42, $x = undef Packaged as a one-liner per the request :-) I'd fire anyone who wrote that for me, though... -- Peter Scott http://www.perldebugged.com/ *** NEW *** http://www.perlmedic.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>