Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!snorkelwacker!mit-eddie!bu.edu!nntp-read!jbw From: jbw@bucsf.bu.edu (Joe Wells) Newsgroups: comp.lang.perl Subject: Re: perl bug with $1, affected by subroutine call Message-ID: Date: 7 Mar 90 00:09:55 GMT References: <7291@jpl-devvax.JPL.NASA.GOV> <7298@jpl-devvax.JPL.NASA.GOV> Sender: news@bu.edu.bu.edu Organization: Boston University Computer Science Department Lines: 48 In-reply-to: lwall@jpl-devvax.JPL.NASA.GOV's message of 6 Mar 90 22:43:13 GMT In article <7298@jpl-devvax.JPL.NASA.GOV> lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes: In article jbw@bucsf.bu.edu (Joe Wells) writes: : Huh? Why is "&sub1" in "&one(&sub1)" being evaluated in an array context? : I intended it to be the single scalar argument to "&one". You can intend all you want--the single item passed to a subroutine call is a LIST, which can have any number of arguments. ^^^^ Ahh, things become clear! Ok. Let me rephrase what you've said and see if you disagree with it. First, the syntax for a subroutine call is like this: do SUB ( LIST ) & SUB ( LIST ) & SUB Second, each item in a LIST is evaluated in an array context. If that item evaluates to an array, each item of the resulting array is added to the list, otherwise the single resulting scalar item is added to the list. Is this a correct restatement, or am I still missing something? : Since the "if" is the last statement of the sub block, it has to be : evaluated in the context that the subroutine was called. : : Huh? Does this mean that an "if" statement has a value, unlike in C? If : so, is there a precise specification of the value of an "if" statement? I : can't find that in the manual. If you look up subroutines you find: do SUBROUTINE (LIST) Executes a SUBROUTINE declared by a sub declaration, and returns the value of the last expression evaluated in SUBROUTINE. What was the last expression evaluated in your subroutine? Not the conditional of the "if" statement! -- Joe Wells jbw%bucsf.bu.edu@cs.bu.edu ...!harvard!bu-cs!bucsf!jbw