Problem with Getopt::Euclid and Empty @ARGV
Today I was working on a pl program that had some existing code using @ARGV. It worked. Then I added:
use Getopt::Euclid;
I was mystified to find out that the code did not work anymore. I did a little RTFM and found that Euclid will populate %ARGV instead of @ARGV. Fun! It makes perfect sense for Euclid to use a hash, but I was confused for a few minutes...
Why did the code compile with array access to a hash?? Because it's Perl!!!
Edit: After more work and more troubleshooting, the ARGV thing is clearing up. We have a lot of existing code that uses %ARGV and @ARGV. Sometimes it easier to access all the elements of an array instead of a hash. This code used to work. Now it is broken since I upgraded Getopt::Euclid. In a certain release of Getopt::Euclid the developer decided to empty out @ARGV. This is documented in the Euclid pod. Now the question is, "What do I do with all that existing code using @ARGV?"
I've got some ideas. One easy, but maybe kind of lame solution is to put a wrapper around Getopt::Euclid and save off @ARGV and reset it after Euclid is done. Or I guess I could change the code. More research is required.
use Getopt::Euclid;
I was mystified to find out that the code did not work anymore. I did a little RTFM and found that Euclid will populate %ARGV instead of @ARGV. Fun! It makes perfect sense for Euclid to use a hash, but I was confused for a few minutes...
Why did the code compile with array access to a hash?? Because it's Perl!!!
Edit: After more work and more troubleshooting, the ARGV thing is clearing up. We have a lot of existing code that uses %ARGV and @ARGV. Sometimes it easier to access all the elements of an array instead of a hash. This code used to work. Now it is broken since I upgraded Getopt::Euclid. In a certain release of Getopt::Euclid the developer decided to empty out @ARGV. This is documented in the Euclid pod. Now the question is, "What do I do with all that existing code using @ARGV?"
I've got some ideas. One easy, but maybe kind of lame solution is to put a wrapper around Getopt::Euclid and save off @ARGV and reset it after Euclid is done. Or I guess I could change the code. More research is required.
Comments
Post a Comment