Some ideas are so simple that they sometimes do not seem to be worth mentioning. This is one of them.
I don't write this:
my @folk = ("Hibbs",
"Daglish",
"Schwartz",
"Vroom");
I write this:
my @folk = ();
push (@folk, "Hibbs");
push (@folk, "Daglish");
push (@folk, "Schwartz");
push (@folk, "Vroom");
Why? It's easier to maintain. You can insert or remove any single line easily, at the beginning, middle, or end. You can remove all the hard-coded lines, or move them to a later point (inside a loop, maybe).
The down-side is that the array name has to be repeated on each line, and there is probably a slight performance penalty.
Now you're going to show me something that uses "qw", aren't you? OK, go ahead, but don't forget to show me how it looks when an entry contains spaces.
Update: make it look less like advice, since it turns out there are better constructs
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.