-w turns on all warnings, globally. To be specific which warnings you want you have to use 'use warnings'. 'use warnings;' also turns on all warnings (in the current scope, so if you place it on top of the file, for the entire file), but then allows you to turn off specific warnings. So, in your case, something like the following would be appropriate:
use strict;
use warnings;
no warnings 'void';
Or you may turn off the warning in a narrower scope (which is what I would do after I had decided the warning can be ignored).