|There's more than one way to do things|
"Useless use of private variable in void context"by Seumas (Curate)
|on Jun 20, 2003 at 20:54 UTC||Need Help??|
Seumas has asked for the
wisdom of the Perl Monks concerning the following question:
I understand the underlying condition which causes a Useless use of private variable in void context error. However, I am encountering this error in at least one spot in my code and no matter what I do to tweak the small portion of code we're dealing with here, I can't make the error go away.
Perhaps the problem is occuring outside of this portion of code (it's a large function/sub so I would rather not post the entire thing unless it's necessary). However, the error specifically indicates the line below..
My code does what I need without any problems, but I'm cleaning up my code in general and this one has really got me.
My program is fairly large (all code totals about 16,000 lines) and the following error apperas with use warnings;.
Useless use of private variable in void context at /home/www/somedomain.com/beta.cgi line 2765.
Line 2765 is this:
GeneratePassword() is the following:
When I run this, $generated_password contains the intended data (a six character password) just as it should. But I still get that error. I have tried parens around $generated_password and even tried doing away with the sub entirely and putting the contents of sub GeneratePassword directly into the calling parent. I still get the same error.
The only thing I could think of was that $1 from the regex match is considered private and "not used", thus useless? But doesn't the fact that $1 is stuffed into $password as the new value of that scalar mean that it is used?
If I haven't provided enough detail, let me know and I'll try to copy in the rest of the calling routine. It's over a hundred lines so I didn't want to pollute this question with even more unless definitely needed.
Hoping this isn't as simplistic and stupid as my gut is telling me it is.