At 12:27 PM 7/11/02 -0500, rory oconnor wrote: >I want to "use strict" in a script I'm writing. I have a separate >config file I am using (require "config.pl";) with a bunch of global >variables. But my script doesn't seem to want to recognize those >variables unless they are actually declared in the body of the script >itself. > >I tried using "my $variable = whatever;" in the config file but it >didn't seem to work either. Does this mean that if I use strict I can >only use variables I declate in the script itself?
The best way to handle this is with the Exporter. It's a bit more work, but it's extensible to anything you want to do: $ cat user #!/usr/bin/perl -l use strict; use warnings; use MyConfig; print "\$foo = $foo"; print "\@bar = @bar"; print "%baz = ", join(' '=> %baz); $ cat MyConfig.pm package MyConfig; use strict; use warnings; use base 'Exporter'; our @EXPORT = qw($foo @bar %baz); our $foo = "one"; our @bar = qw(two three); our %baz = (four => 4, five => 5); 1; $ ./user $foo = one @bar = two three %baz = five 5 four 4 $ There are some 5.6 things in there that we can show you the old ways of doing if you don't have 5.6 or greater. -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]