Hello Mongers:

Recently I've been learning Java, and right now im looking at how Java variables work.

For example, when you initialize a variable in Java you must first define what kind of values that variable can hold:

int i = 10; short s = 24000;

When you initialize a variable, Java makes a block of space in the memory for that variable knowing how much space it can hold.

But in perl, we have a "universal" variable, for example a string ($) can hold ints, strings, floats, almost anykind of data. So you can do something like this:

my $stringa = 1234; $stringb = "Hello"; $stringa = $stringb; #No cast problem

Knowing this, my question is: How does perl work with variables?

I've been thinking that when perl makes some space for a variables, it still has to keep in mind that the variable might change in size.

I tried to find some article on the web, but without success.

THANKS

If you're a spanish spoken programmer go to my site: Perl en Espaņol

In reply to Behind the Scenes - Perl Variables by kidd

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.