It's time to stop being a leech!
We're here to help you learn, but not to do your job, nor even to do your job of educating yourself. This question clearly means you haven't read the most basic information about scoping nor about the implication of declarring variables my $var... nor -- well, you've provided too many examples of failing to help yourself to bother listing them all. A quick review of your posts says that's a consistent behavior.
Questions containing the words "doesn't work" (or their moral equivalent) will usually get a downvote from me unless accompanied by:
- verbatim error and/or warning messages
- a coherent explanation of what "doesn't work actually means.