Re: Problem with Hashes

From: Sherm Pendley (spamtrap_at_dot-app.org)
Date: 11/19/04


Date: Fri, 19 Nov 2004 16:57:11 -0500

daniel kaplan wrote:

> have a variable of 'this kind'?
>
> well don't use it in 'this kind' context and the compiler will let you know,
> and boom problem found quickly.....but with Perl you can have @row, $row,
> $row[0], and so on and so on and it makes you have to be more digilent as
> the programmer....

Context is very important in Perl. Subroutines can find out what context
they were called in with wantarray(), and alter their return value(s)
accordingly. An array used in scalar context has a different value than
one used in list context. Etc.

It can be painful for a C programmer who's accustomed to strict typing,
but context is an idea that's central to Perl and it's well worth learning.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


Relevant Pages

  • Re: Overloading and method signatures.
    ... some part of my brain has been spoiled by Perl. ... Console.WriteLine("the number is " + theNumber); ... Knowing that the expression is in "string context", the compiler calls ...
    (microsoft.public.dotnet.csharp.general)
  • Re: Overloading and method signatures.
    ... some part of my brain has been spoiled by Perl. ... Console.WriteLine("the number is " + theNumber); ... Knowing that the expression is in "string context", the compiler calls ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Question on a perlsub statement.
    ... operator would read multiple lines. ... Because the readline does not know, nor does it need to know, ... context before it would know what behavior it should exhibit. ... Here's how I thought how Perl should've ...
    (comp.lang.perl.misc)
  • Re: While query
    ... > Ben Morrow wrote: ... > the Perl compiler is implemented and looking only at the observable ... two models predict the same behaviour, since context is determined at ... model easier to understand than the other. ...
    (comp.lang.perl.misc)
  • Re: Perl vs Python vs Ruby
    ... I think it makes perfect sense in the context of Perl. ... > and that being able to use %foo, @foo, ... > Ruby is closely related to Smalltalk and Lisp. ...
    (comp.lang.perl.misc)