UPDATE : Got the description of the variable wrong.
Monks of the perl code,

this humble novice once more would request you to look up from your tomes and spare this unworthy son a few moments of your valuable time.

For some time now, I find myself among your midst. When I first came in here, I donned my robe with pride and shared much interesting times in this monastery, which has become my home away from home, and I have gained much knowledge.

Though still, from time to time, I notice small errors in my code. They are not fatal, wise ones, yet they are inefficient use of code which could be great, if only for knowledge I yet not posess.

Earlier today, I discovered such an error. It was as such:($data is a reference to an array of references to arrays)

foreach my $record(@$data) {print @$record[0];}
This is how my code used to be. Today, to see if it could be done, I wrote this:

foreach(@$data) {print @$_[0];}
Which, to my surprise, worked!. This proves all my previous code could contain these horrid unefficiencies.
I have been taught the holy verse of TMTOWTDI, but still, this I must ask, where lie the boundaries of efficient and inefficient code? Was this bad code? What should be paid attention to when writing code?

I realize that this question addresses a very broad spectrum, which I ask your forgiveness for. Still, I felt I had to ask it. I must learn in order to know.

Your fellow scribe,

-- Detonite


In reply to Using aliases in for loops or not? by jkva

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.