Hi,
I've run up against a problem at the last stage of a script I've written. Everything worked on a test script, but when I add the subroutines to the Actinic perl scripts it ceases to work.
Essentially I'm trying to read in the contents of another perl file at runtime using require(). This external file holds one hash containing some stock levels. On my test script, the following worked great:
stock.pl contains:
I then inserted this inside a function in ShoppingCart.pl. The function runs OK, and require() seems to pickup the file, but $stockLevel remains unassigned. I've also tried eval ("stock.pl") and eval ("require stock.pl") with no results.
$stockLevels just isn't being assigned. If I assign some values to the hash, then read in the file, the original hash remains unaffected and I can access the original values. I'm assuming this is some kind of variable scope problem but I really don't know that much about Perl, and I'm tearing my hair out.
Can anyone from Actinic or any perl masters shed any light on this? Thanks in advance
Graham
I've run up against a problem at the last stage of a script I've written. Everything worked on a test script, but when I add the subroutines to the Actinic perl scripts it ceases to work.
Essentially I'm trying to read in the contents of another perl file at runtime using require(). This external file holds one hash containing some stock levels. On my test script, the following worked great:
Code:
my %stockLevels; # initialise the hash require ("stock.pl"); # read in the file with the new hash my $stockLevel=$stockLevels{'product1'}; # grab the stock level
Code:
%stockLevels=('product1'=>12,'product2'=>50); 1;
$stockLevels just isn't being assigned. If I assign some values to the hash, then read in the file, the original hash remains unaffected and I can access the original values. I'm assuming this is some kind of variable scope problem but I really don't know that much about Perl, and I'm tearing my hair out.
Can anyone from Actinic or any perl masters shed any light on this? Thanks in advance
Graham
Comment