Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Unknown perl idiom using : (colon)

by RHainsworth (Acolyte)
on Aug 19, 2007 at 12:22 UTC ( #633596=perlquestion: print w/replies, xml ) Need Help??
RHainsworth has asked for the wisdom of the Perl Monks concerning the following question:

I found the following use of : in a module. I have scanned the perl docs I thought relevant (tie and module), but cant find what it means. Can anyone point me to an explanation of what is happening?

The specific line is my $value: Value = 0;

I know that Value is a package below XUL::Node::MVC but what I cant figure out is what '$value:' is doing, or is it ': Value'? Is this a tie? Is it a shortcut for Value->new? The context is in an example (XUL/Node/Application/ in XUL::Node viz.,

use strict; use warnings; use Carp; use XUL::Node::MVC; use base 'XUL::Node::Application'; sub start { my $value: Value = 0; # <--- I dont understand this line Window(SIZE_TO_CONTENT, VBox( HBox( Button(label => '+', Click => sub { $v +alue++ }), Button(label => '-', Click => sub { $v +alue-- }), ), Label(value => $value), TextBox(DISABLED, value => $value), ), ); return tied($value); # DO NOT REMOVE!- this is for unit testing MVC # and for unit tests only. Lets us check the valu +e # from the outside } 1;

Replies are listed 'Best First'.
Re: Unknown perl idiom using : (colon)
by moritz (Cardinal) on Aug 19, 2007 at 12:25 UTC
Re: Unknown perl idiom using : (colon)
by jdporter (Canon) on Aug 19, 2007 at 13:10 UTC
      thank you both for the clue.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://633596]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2017-12-11 20:11 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (311 votes). Check out past polls.