Home: Perl Programming Help: Intermediate:
Need help with glob

New User

Jul 4, 2005, 11:27 PM

Views: 927
Need help with glob

Hi all,

Having problems with glob function. We are involved in a migration of an application from perl 5.005_03 to perl 5.6.1. This is an old and critic app code, so we don't want to modify it. In the application, we are reading from a database a string, containing an environment variable (e.g. $PATH), we store the value read into a perl structure and then we use glob to expand the environment variable ( I know that this is not the right use of glob) $a_variable = glob $structure->value;

$command ="value $a_variable";

When executing this in perl 5.005_03 we have in the $command the environment variable expanded. If we execute in perl 5.6.1 we have the string $PATH in $command="value $PATH".

We can solve this in the right way using reg exp to substitute the $PATH. But we don't want to change the code. The problem seem to be related to the change in glob implementation from perl 5.6.0, now perl is not calling to glob function from the unix operating system, it's calling a new implementation of glob from perl's core.

Do you know any way of maintain backwards compatibility ??? any way of still calling to glob from Unix without changing the code ???

Thanks in advance

Thaumaturge / Moderator

Jul 5, 2005, 8:41 AM

Views: 921
Re: [adiezsoto] Need help with glob

Sounds like you've been relying on a bug in "glob" that got fixed :)

The correct way to access environment variables is by using the %ENV hash. For example, the enviroment variable $PATH is in $ENV{PATH}.

Dave Cross, Perl Hacker, Trainer and Writer
Get more help at Perl Monks