It appears to me that the best solution is to declare the variables with our. Is there any way to do this without writing our for each variable or without listing all of the variable names within an our declaration and again when I assign values to them?

Since I am only writing a report with Perl, I don't have a lot of stuff competing for the namespace. I would like to keep the readability high and the amount of redundancy low so that the code is easy to change and easy to read. If I package this into an object with getters and setter later then I can find and replace our with my, but for now I think that our seems to be the best choice. Thoughts?

use strict; # while I would like to do this: # # our # ( # $x = 1; # $y = 2; # ); # # it seems that I must do: use ($x, $y); $x = 1; $y = 2; # or this: our $x = 3; our $y = 4; # before I can do: $x = 5; $y = 6;

should I do the following instead?

use strict; no strict "vars"; $x = 5; $y = 6;

Thank you,


In reply to Is use strict always appropriate? by Je55eah
in thread Please help me print this hash. by Je55eah

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.