The important idea to understand here is 'scope'. Scope describes the chunk of code where an identifier is recognized as being tied to a specific something (variable name, subroutine name, ...). For lexical variables (the ones declared using my) the scope is from the declaration to the end of the current block. {} is used to enclose a block and they may be nested (blocks in blocks).
In your sample you had three blocks, each with a (different) variable called $zipexe declared in it. Since each $zipexe goes out of scope (can't be seen any more) at the end of the block it is declared in, none are visible in the outer block containing the print statement. To fix the problem you need to have just one declaration for $zipexe before the first if so that the same variable is used in each place.
Note that this is a feature and contributes to why strict can pick up coding errors. If you make a habit of declaring variables in the smallest sensible scope strict can often let you know when you are trying to use a variable inappropriately (as indeed was the case here).
Note that as well as using strict you should also use warnings which will tell you about things that are going wrong at run time, such as the contents of variable being used before the content has been set (a very common problem btw).
In reply to Re: Stupid If Question
by GrandFather
in thread Stupid If Question
by Lrdtalon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |