Re: using (sharing) variables between perl files

2006-06-19 Thread Jeff Peng




The "best" way to do it in your case will vary, depending on what
exactly you're doing with your Perl scripts.



I do agree that.If you develop large programs where multi-processes should 
share some variables (including scalar,array or hash),you could use DB_File 
or other database  to store and share varibles across those multi-processes.

Also you could see this article:
http://www.perl.com/pub/a/2002/04/23/mod_perl.html?page=1



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: using (sharing) variables between perl files

2006-06-19 Thread Chad Perrin
On Mon, Jun 19, 2006 at 05:02:33PM +0200, Varga Pavol wrote:
> Hi,
> may be very simple, but I don't understand well how to simple use (share)
> varables between perl files?
> I have (very) big perl script and I would like to divide it into more small
> scripts to make it all more transparent.
> Or, how to use one @array or one $array_ref for more than one file.pl?

To summarize what others have said:

You can include the code of one Perl file in another via "use" or
"require", and you can save variable data in an external file (such as a
config file) that each separate Perl script parses to populate
variables.  You could even simply have one script call another, and get
output from that other for use as variable data in the script that
called it.

The "best" way to do it in your case will vary, depending on what
exactly you're doing with your Perl scripts.

-- 
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
unix virus: If you're using a unixlike OS, please forward
this to 20 others and erase your system partition.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: using (sharing) variables between perl files

2006-06-19 Thread Anthony Ettinger

On 6/19/06, Prabu <[EMAIL PROTECTED]> wrote:

Varga Pavol wrote:
> Hi,
> may be very simple, but I don't understand well how to simple use (share)
> varables between perl files?
> I have (very) big perl script and I would like to divide it into more small
> scripts to make it all more transparent.
> Or, how to use one @array or one $array_ref for more than one file.pl?
>
> I just read book from OReilly - Learning perl and some chapters about
> Intermediate perl, but I am little bit confused with objects, packages and
> probably more ... :-(
>
>
> Many thanks.
>
>
Hello ,

Hope this Small example give you some idea.

 $cat file1.pl
#!/usr/bin/perl
$name="prabu";

$cat file2.pl
#!/usr/bin/perl
require "file1.pl";
print $name."\n";

$ perl file2.pl
prabu


--
Prabu.M.A

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 





read about object oriented perl. or you can always use a config file.

--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: using (sharing) variables between perl files

2006-06-19 Thread Prabu

Varga Pavol wrote:

Hi,
may be very simple, but I don't understand well how to simple use (share)
varables between perl files?
I have (very) big perl script and I would like to divide it into more small
scripts to make it all more transparent.
Or, how to use one @array or one $array_ref for more than one file.pl?

I just read book from OReilly - Learning perl and some chapters about
Intermediate perl, but I am little bit confused with objects, packages and
probably more ... :-(


Many thanks.

  

Hello ,

Hope this Small example give you some idea.

$cat file1.pl
#!/usr/bin/perl
$name="prabu";

$cat file2.pl
#!/usr/bin/perl
require "file1.pl";
print $name."\n";

$ perl file2.pl
prabu


--
Prabu.M.A

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: using (sharing) variables between perl files

2006-06-19 Thread M. Kristall

Varga Pavol wrote:

Hi,

Hello

may be very simple, but I don't understand well how to simple use (share)
varables between perl files?
I have (very) big perl script and I would like to divide it into more small
scripts to make it all more transparent.
perldoc is your friend. If you have separate 'package's within your 
file, see 'use' . Otherwise, 
you probably want 'require' 
 (or 'do' 
 if you don't want your 
program to immediately quit if a file couldn't be included).

Or, how to use one @array or one $array_ref for more than one file.pl?

After including files, you just use those variables as you would any others.


Many thanks.

Your welcome (and I hope I helped).

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




using (sharing) variables between perl files

2006-06-19 Thread Varga Pavol
Hi,
may be very simple, but I don't understand well how to simple use (share)
varables between perl files?
I have (very) big perl script and I would like to divide it into more small
scripts to make it all more transparent.
Or, how to use one @array or one $array_ref for more than one file.pl?

I just read book from OReilly - Learning perl and some chapters about
Intermediate perl, but I am little bit confused with objects, packages and
probably more ... :-(


Many thanks.

-- 
palo

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]