Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2016-10-25 03:41 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (313 votes). Check out past polls.