Ken Killer wrote: > I load the config file in the main program using do, > <main.pl> > #!perl > do "conf"; > use strict; > print "value of v is $v\n"; > ------------------------------------ > and the config file has only one line, > <conf> > $v = 'hello'; > > when I run the main.pl, it reports following error, how to fix this? > > Global symbol "$v" requires explicit package name at main.pl line 4. > Execution of main.pl aborted due to compilation errors. >
perldoc -f do Specifically the section for 'do EXPR' and more specifically the example at the bottom. You should be error checking your call to 'do'. And of particular importance is the line: "Note that inclusion of library modules is better done with the "use" and "require" operators, which also do automatic error checking and raise an exception if there's a problem." In this case you need to provide the package name for $v because it hasn't been declared, or declare it with 'our'. perldoc -f our Either in 'main.pl', add: our $v; or use, print "value of v is $::v\n"; Of course there are better ways to handle program configuration, there are numerous modules on CPAN for handling all manners of formatted config files. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>