in reply to Declaring variables - is it legal to do this?

I'm confused. Why would you ask, "Is it legal Perl to do XXXX"? The obvious way to find out is to write a script with one or a few lines of code, and see how the Perl program reacts to it. Forgive me if I seem blunt, but in the time you wrote your message, you could have determined the answer.

If what you really mean is, "This compiles, but I don't understand what it is", why not ask that question?

--
TTTATCGGTCGTTATATAGATGTTTGCA

  • Comment on Re: Declaring variables - is it legal to do this?

Replies are listed 'Best First'.
Re: Re: Declaring variables - is it legal to do this?
by theon (Beadle) on May 15, 2004 at 12:59 UTC
    I'm a Perl newbie, and I'm very surprised by those 3 answers, that say "Try it, and you'll see". You wouldn't say that with some other languages (such as C or C++) because of undefined or unspecified behaviours: it may compile, it may work how you expected (with your compiler), but that's not enough to be sure the behaviour is guarranted. Personnaly, I would have asked such a question, even after trying it, to be sure I'm not wrong.
    I understand why people love Perl :)

      Yes, but there's only one Perl interpreter, so whatever the doncumentation says, the interpreter (perl) is always right. (Larry is always right, in other words.)

      my (undef) surprised me a bit btw.

        Well since perl is written in C, there could be unspecified behaviours in Perl itself (ie. having different valid results for the same code with different platforms), but I guess Perl was designed to avoid that.