home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / perl / 7527 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  1.6 KB

  1. Path: sparky!uunet!eiffel!eiffel.com
  2. From: ram@eiffel.com (Raphael Manfredi)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: system() vs exec()
  5. Message-ID: <162@eiffel.eiffel.com>
  6. Date: 18 Dec 92 18:02:40 GMT
  7. References: <2B30B274.616E@tct.com> <mcook.724624157@fendahl.dev.cdx.mot.com> <2B31E577.99FA@tct.com>
  8. Sender: ram@eiffel.com
  9. Organization: Interactive Software Engineering, Santa Barbara CA
  10. Lines: 39
  11.  
  12. Quoting chip@tct.com (Chip Salzenberg) from comp.lang.perl:
  13. >According to mcook@fendahl.dev.cdx.mot.com (Michael Cook):
  14. >>Besides, you've used @_ after you used local().  That's a Perl no-no.
  15. >
  16. >Oh?
  17.  
  18. It's not a Perl no-no, rather a perl 4.0 no-no.
  19.  
  20. If you declare:
  21.  
  22.     local($pid);
  23.  
  24. and then use '@_' to refer to the argument list for your routine, then there
  25. is a possibility, a chance (sic), that somehow your parameter gets clobbered
  26. by the local declaration.
  27.  
  28. Example:
  29.  
  30. sub foo {
  31.     local($pid) = '1';
  32.     print "Argument #1: $_[0]\n";
  33. }
  34.  
  35. &foo('ls');        # Prints 'ls', as you'd expect
  36. $pid = 'ls';
  37. &foo($pid);        # Prints '1', surprise!?
  38.  
  39. Of course, because @_ contains references to the symbol table, instead of a
  40. reference to the true value of the parameter. Since perl 5.0 will have
  41. true references, we can hope this problem will be fixed.
  42.  
  43. (Note: this is an implementation problem, not a conceptual one. I pointed that
  44. out to Michael in private e-mail and he replied that (paraphrasing) Perl
  45. was 'practical', not conceptual.)
  46. -- 
  47. Raphael Manfredi <ram@eiffel.com>
  48. Interactive Software Engineering Inc.
  49. 270 Storke Road, Suite #7                      / Tel +1 (805) 685-1006 \
  50. Goleta, California 93117, USA                  \ Fax +1 (805) 685-6869 /
  51.