Re: separating code in two files

2013-03-02 Thread Rob Dixon
On 02/03/2013 14:37, Chris Stinemetz wrote: On Fri, Mar 1, 2013 at 3:37 PM, Chris Stinemetz wrote: On Fri, Mar 1, 2013 at 11:00 AM, Shlomi Fish wrote: Hi Jim, On Thu, 28 Feb 2013 11:21:59 -0800 Jim Gibson wrote: On Feb 28, 2013, at 10:31 AM, Chris Stinemetz wrote: I want to put a has

Re: separating code in two files

2013-03-02 Thread Jim Gibson
On Mar 2, 2013, at 6:37 AM, Chris Stinemetz wrote: > With Shlomi's approach how would I access each element in the %global_hash > within the main script calling the function? > > Below is what I have attempted. > > **Containers.pm** > > ## This is the file Containers.pm > package Containers;

Re: separating code in two files

2013-03-02 Thread Chris Stinemetz
On Fri, Mar 1, 2013 at 3:37 PM, Chris Stinemetz wrote: > > > On Fri, Mar 1, 2013 at 11:00 AM, Shlomi Fish wrote: > >> Hi Jim, >> >> On Thu, 28 Feb 2013 11:21:59 -0800 >> Jim Gibson wrote: >> >> > >> > On Feb 28, 2013, at 10:31 AM, Chris Stinemetz wrote: >> > >> > > I want to put a hash declaratio

Re: separating code in two files

2013-03-01 Thread Chris Stinemetz
On Fri, Mar 1, 2013 at 11:00 AM, Shlomi Fish wrote: > Hi Jim, > > On Thu, 28 Feb 2013 11:21:59 -0800 > Jim Gibson wrote: > > > > > On Feb 28, 2013, at 10:31 AM, Chris Stinemetz wrote: > > > > > I want to put a hash declaration in a separate file from the main > script. > > > How do I do this cor

Re: separating code in two files

2013-03-01 Thread Shlomi Fish
Hi Jim, On Thu, 28 Feb 2013 11:21:59 -0800 Jim Gibson wrote: > > On Feb 28, 2013, at 10:31 AM, Chris Stinemetz wrote: > > > I want to put a hash declaration in a separate file from the main script. > > How do I do this correctly? > > > > perl.pl ( main script ) > > > > #!/usr/bin/perl > > us

Re: separating code in two files

2013-02-28 Thread Chris Stinemetz
> > > > Put the following line in the main script: > > our %hash; > > Change the "my %hash = ( ... );" declaration in lib.pl to "our %hash = > (...);". > > In your original versions, %hash was a lexical variable in lib.pl, and > thus not in scope within perl.pl. Using 'our' instead of 'my' makes %h

Re: separating code in two files

2013-02-28 Thread Jim Gibson
On Feb 28, 2013, at 10:31 AM, Chris Stinemetz wrote: > I want to put a hash declaration in a separate file from the main script. > How do I do this correctly? > > perl.pl ( main script ) > > #!/usr/bin/perl > use warnings; > use strict; > use Data::Dumper; > > require "lib.pl"; > > print Dump

separating code in two files

2013-02-28 Thread Chris Stinemetz
I want to put a hash declaration in a separate file from the main script. How do I do this correctly? perl.pl ( main script ) #!/usr/bin/perl use warnings; use strict; use Data::Dumper; require "lib.pl"; print Dumper \%hash; lib.pl ( library script ) #!/usr/bin/perl use warnings; use strict;