X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=samples%2Fbasic.pl;fp=samples%2Fbasic.pl;h=9e38f1306f4a175013496775d84c8d620c39d21d;hb=d7bc605f5faa98d26edda28996af1377d5ec1bcf;hp=e35d8526f1c55b299e245c5df65b42cc3ba8a33b;hpb=cdabc1884bd85c70f2cb491a669113fdf7aba11c;p=perl%2Fmodules%2FLexical-Types.git diff --git a/samples/basic.pl b/samples/basic.pl index e35d852..9e38f13 100644 --- a/samples/basic.pl +++ b/samples/basic.pl @@ -3,14 +3,30 @@ use strict; use warnings; +use blib; + +{ package Str; } + +{ + package My::Types::Str; + + sub new { bless { }, shift } +} + +use Lexical::Types as => sub { 'My::Types::' . $_[0] => 'new' }; + +my Str $x; # $x is now a My::Types::Str object +print ref($x), "\n"; # My::Types::Str; + { - package Str; + package My::Types::Int; - sub TYPEDSCALAR { $_[1] = ' ' x 10 } + sub TYPEDSCALAR { bless { }, shift } } use Lexical::Types; -my Str $x; +use constant Int => 'My::Types::Int'; -print length($x), "\n"; # 10 +my Int $y; # $y is now a My::Types::Int object +print ref($y), "\n"; # My::Types::Int;