This is not only true of perl and Java. In my C++ class I learned many, easily 20+ lines of code, difficult ways to create unlimited arrays. Once I looked at the standard headers included with C++, this was 4 years ago, I noticed vector.

#include <vector> #include <iostream> std::vector<char> array; char c = 0; while(c != 'X' || c != 'x') { //enter something or exit to quit std::cin>>c; array.push_back(c); //remind you of anything ;) } std::cout<<array.size()<<std::endl; /* btw., the way I learned to get an arrays length was to create a sec +ond int array as a counter*/

As for why the One Way, or more approapriately Best Way is ignored, that's a good question

"Cogito cogito ergo cogito sum - I think that I think, therefore I think that I am." Ambrose Bierce


In reply to Re: There's Only One Way To Do It by kutsu
in thread There's Only One Way To Do It by jdporter

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.