How to do? Possible?

2011-07-25 Thread Linda Walsh
I got great help in learning about how to do the perl equiv of (var1, var2, var3)= (list) using read var1 var2 var3 (list). I use it often to get back lists of values from subroutine calls, but with sometimes useful, and sometimes hindering fact that when I do read var1 var2 var3 $(function x

Re: How to do? Possible?

2011-07-25 Thread Pierre Gaston
On Mon, Jul 25, 2011 at 12:20 PM, Linda Walsh b...@tlinx.org wrote: I got great help in learning about how to do the  perl equiv of (var1, var2, var3)= (list) using read var1 var2 var3 (list). I use it often to get back lists of values from subroutine calls, but with sometimes useful, and

Re: How to do? Possible?

2011-07-25 Thread Steven W. Orr
On 7/25/2011 5:20 AM, Linda Walsh wrote: I got great help in learning about how to do the perl equiv of (var1, var2, var3)= (list) using read var1 var2 var3(list). I use it often to get back lists of values from subroutine calls, but with sometimes useful, and sometimes hindering fact that

Re: How to do? Possible?

2011-07-25 Thread Linda Walsh
Pierre Gaston wrote: Since you are already using global variables, why not simply use a couple more for the return values? --- Because a subshell cannot access the global variables of the parent. The only 'hack' I came up with overnight for a quick dirty, is to pass

Re: How to do? Possible?

2011-07-25 Thread DJ Mills
       Because a subshell cannot access the global variables of the parent. A subshell can access its parent's variables. foo=bar; ( echo $foo ) A sub process cannot, unless the variables are exported. It does not sound like you need to do so here.

Re: How to do? Possible?

2011-07-25 Thread Linda Walsh
Steven W. Orr wrote: On 7/25/2011 5:20 AM, Linda Walsh wrote: I highly recommend reading this, but read it *very carefully*. I have adopted this in my production system and it works great. The idea is to implement passing variables by reference and to allow the values to be either scalars

Re: How to do? Possible?

2011-07-25 Thread Pierre Gaston
On Mon, Jul 25, 2011 at 8:33 PM, Linda Walsh b...@tlinx.org wrote: Pierre Gaston wrote: Since  you are already using global variables, why not simply use a couple more for the return values? ---        Because a subshell cannot access the global variables of the parent. uh? you don't make

Re: How to do? Possible?

2011-07-25 Thread Linda Walsh
DJ Mills wrote: Because a subshell cannot access the global variables of the parent. A subshell can access its parent's variables. foo=bar; ( echo $foo ) A sub process cannot, unless the variables are exported. It does not sound like you need to do so here. I'm not sure

Re: How to do? Possible?

2011-07-25 Thread Bob Proulx
Linda Walsh wrote: DJ Mills wrote: Because a subshell cannot access the global variables of the parent. A subshell can access its parent's variables. foo=bar; ( echo $foo ) A sub process cannot, unless the variables are exported. It does not sound like you need to do so here.

Re: How to do? Possible?

2011-07-25 Thread Linda Walsh
Bob Proulx wrote: Linda Walsh wrote: DJ Mills wrote: Because a subshell cannot access the global variables of the parent. A subshell can access its parent's variables. foo=bar; ( echo $foo ) A sub process cannot, unless the variables are exported. It does not sound like you need to do

Re: How to do? Possible?

2011-07-25 Thread Linda Walsh
Linda Walsh wrote: Bob Proulx wrote: Yes, but it is a fork(2) of the parent shell and all of the variables from the parent are copied along with the fork into the child process and that includes non-exported variables. Normally you would expect that a subprocess wouldn't have access to

Re: How to do? Possible?

2011-07-25 Thread Eric Blake
On 07/25/2011 03:45 PM, Linda Walsh wrote: I mistyped that but it brings me to an interesting conundrum: GLOBAL=hi there {foo=GLOBAL echo ${!foo}; } This says: evaluate ${!foo}, and pass that expansion to 'echo', with foo=GLOBAL in the environment of echo. You are invoking behavior that

Re: How to do? Possible?

2011-07-25 Thread Davide Brini
On Mon, 25 Jul 2011 14:28:52 -0700, Linda Walsh b...@tlinx.org wrote: Not really. It only seems that way because within () any $ is usually expanded BEFORE the () starts from the parent You can see this by GLOBAL=hi there (echo $GLOBAL) prints out hi there as expected,

Re: How to do? Possible?

2011-07-25 Thread Linda Walsh
Eric Blake wrote: On 07/25/2011 03:45 PM, Linda Walsh wrote: I mistyped that but it brings me to an interesting conundrum: GLOBAL=hi there {foo=GLOBAL echo ${!foo}; } This says: evaluate ${!foo}, and pass that expansion to 'echo', with foo=GLOBAL in the environment of echo. You are

Re: How to do? Possible?

2011-07-25 Thread Bob Proulx
Linda Walsh wrote: I didn't know why it behaved differently, but as you informed me the difference is 'one's well-defined, and the other is not, I can see why there 'could' be a difference... ;-) (which of course could change tomorrow, I suppose..) Not the second well defined case. It

Re: How to do? Possible?

2011-07-25 Thread Dennis Williamson
On Mon, Jul 25, 2011 at 4:45 PM, Linda Walsh b...@tlinx.org wrote: Linda Walsh wrote: Bob Proulx wrote: Yes, but it is a fork(2) of the parent shell and all of the variables from the parent are copied along with the fork into the child process and that includes non-exported variables.  

Re: How to do? Possible?

2011-07-25 Thread Dennis Williamson
Sorry, I overlooked the indirection (and the missing semicolon). On Mon, Jul 25, 2011 at 10:18 PM, Bob Proulx b...@proulx.com wrote: Dennis Williamson wrote: Linda Walsh wrote: GLOBAL=hi there {foo=GLOBAL echo ${!foo}; } Note that this tickles a problem since foo isn't set before $foo is