in reply to variable passing....

Perl has no global variables. It sounds like you may want to look into one of two possibilities...
1 - Have program two call require 'program_one.pl' at some point before it needs to use $total_orange, this technique will allow you to put $total_orange in the main package and use it as you want.
2 (better) - Make program one a seperate package (ie. package Program_one with a function which can be called to calculate and return the desired value. Then program two needs to use Program_one; and run my $total_orange = Program_one::oranges();. This is the more desireable solution because it helps you to learn about files, packages and modules in perl.

Replies are listed 'Best First'.
Re: Re: variable passing....
by arturo (Vicar) on Dec 11, 2000 at 19:58 UTC

    Stop that train! Perl has global variables. What you may be thinking is that each package global exists in its own namespace, so $foo in package Foo is a distinct entity from $foo in package Bar. But all that means is that while you're in package Bar, $foo refers to $Bar::foo. A variable declared in a package (with use vars or, in 5.6, our) is global within that package (e.g. every subroutine in that package can see and modify that variable (unless it's masked by a my declaration -- i.e. within a block (or, if used outside of a block, a file), use of $foo will refer to the variable declared with my $foo)

    You may have been thinking that under use strict 'vars', you need to declare variables with my before you can refer to them, but that's not really true (e.g. you can use vars -- for the skinny, see strict (even better the man page on your system) or tye's writeup strict.pm)

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor

      I'm aware that perl has locally global variables.
      However I thought the poster referred to globals in VB, which as I recall if declared in a module can be package globals in all packages simultaneously. However my recall may be incorrect since I have seen the light of the holy Perl and left icky VB behind (in other words I haven't used it for a while). Any way this would mean that one instance of the global var $foo is accessible in all packages without using a fully qualified name. This can be useful for a very common function, status variable or a useful constant. However perl does not have global globals and that is the question I was answering.