Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: subroutine inspecting its calling environment Message-ID: <7319@jpl-devvax.JPL.NASA.GOV> Date: 7 Mar 90 18:56:31 GMT References: <7283@jpl-devvax.JPL.NASA.GOV> <100405@convex.convex.com> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 41 In article <100405@convex.convex.com> tchrist@convex.COM (Tom Christiansen) writes: : Really? $#_ has always worked for me: : : : #!/usr/bin/perl : : &callme; : &callme('blue'); : &callme(0); : &callme(7,1); : &callme(); : : exit 0; : : sub callme { : local($count) = $#_ + 1; # assumes $[ == 0 : printf "i was called with %s argument%s\n", : $count, ($count == 1) ? '' : 's'; : } : : : Is there some reason this is not reliable? #!/usr/bin/perl &callme; &callfrom(1,2,3); exit 0; sub callme { local($count) = $#_ + 1; # assumes $[ == 0 printf "i was called with %s argument%s\n", $count, ($count == 1) ? '' : 's'; } sub callfrom { &callme; } Larry