http://qs1969.pair.com?node_id=591939


in reply to Declaring a Variable [for BEGINNERS]

Hi,
Welcome to Perl!
Delaring variables can be done at the beginning of your program/code or at the point where you being to use those variables in the code.
For example,you may declare varaibles at the beginning of your code as in -
#!/usr/bin/perl use strict; use warnings; my $variable1; my $variable2; ... ... ### Rest of the code follows from below ... ... ### End of the code
Also, if you are declaring variables close to the point where you begin to actually use them, you may do something as below:
#!/usr/bin/perl use strict; use warnings; .... .... ... for (my $variable1=0; $variable1 <= $#someArray; $variable++) { ### Do something here ... ... } ... ### Rest of the code here ...

Best Regards,
garbage777