$output = $output . "<td$recentChange><div title=\"Changed by $moduleF
+ie
ld[1] at $localtime\" class=table_data onClick=\"ToggleShowHide('label
+_$headers[$dataCount]$moduleCount','$headers[$dataCount]$moduleCount'
+)\" id=\"label_$headers[$dataCount]$moduleCount\" style='display: blo
+ck;'>$moduleField[0]</div> <div id=\"$headers[$dataCount]$moduleCount
+\" style='display: none;'><input type=text name=\"$headers[$dataCount
+]$moduleCount\" value=\"$moduleField[0]\"><input type=button onClick=
+\"ToggleShowHide('label_$headers[$dataCount]$moduleCount','$headers[$
+dataCount]$
moduleCount')\" value=OK></div></td>";
.... is pretty darned ugly (no offense intended).
You could tidy that up somewhat, and make it a bit more readable, by doing something like:
$output .= qq(
<td$recentChange>
<div title="Changed by $moduleField[1] at $localtime"
class=table_data
onClick="ToggleShowHide('label_$headers[$d_cnt]$m_cnt','$h
+eaders[$d_cnt]$m_cnt')"
id="label_$headers[$d_cnt]$m_cnt"
style='display: block;'>
$moduleField[0]
</div>
<div id="$headers[$d_cnt]$m_cnt"
style='display: none;'>
<input type=text name="$headers[$d_cnt]$m_cnt" value="$mod
+uleField[0]">
<input type=button
onClick="ToggleShowHide('label_$headers[$d_cnt]$m_cnt'
+,'$headers[$d_cnt]$m_cnt')"
value=OK>
</div>
</td>
);
Notes:
- $foo .= $bar is the same as $foo = $foo . $bar
- use the quoting operators (qq - look for "Regexp Quote-Like Operators" in perlop) in preference to double-quotes - saves lots of messing about escaping special characters.
- Whilst descriptive variable names are generally considered a good thing™, if you make them too long you wind up with big long statements like the one above, that are difficult to read and understand. Consider shortening some of your variable names - especially those that have limited scope. A good rule of thumb is that the shorter the scope, the shorter the name.
- When you have a big long statement like the one above, split it over several lines and use indenting for vertical alignment, to improve readability (and make debugging easier).
Hope this helps,
Darren :)
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.