I'm using a pair of arrays containing anonymous hashes to add URLs to some Item ID's for our stockroom's online catalog. To do this, I use the following code to add a key/value pair to those anonymous hashes:
$n=0; for my $el (@products) { if ( exists $products[$n]{"Vendor Item ID"} ) { $m = 0; for my $el (@config) { if ( exists $config[$m]{Vendor} ) { if ( $config[$m]{Vendor} =~ /$products[$n]{Name}/ ) { $url= $config[$m]{URL}; $url=~ s/\*/$products[$n]{"Vendor Item ID"}/g; $products[$n]{TaggedID} = $url; } } $m++; } } $n++; }
This works fine--as long as I don't use strict. The problem is that if I use strict, and declare the $url variable with 'my', running that substitution seems to clear out the variable, so that $products$n{TaggedID} gets set to nothing.
Why? And on a related note, is there a better way to do this? I'm still pretty new to perl.
For reference, one of the URLs looks like this: http://www1.qiagen.com/Search/Search.aspx?SearchTerm=*and the idea is to trade the * for whatever is in the 'Vendor Item ID' column, then store that in the appropriate hash.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |