in reply to #!/usr/bin/perl -w and use warnings;

You've already got the correct answer. Just one more comment: the -w flag is equivalent to BEGIN { $^W = 1; }