in reply to Re: Foo->new() vs. new Foo()
in thread Foo->new() vs. new Foo()
And heres the output from running foo_test.pl# this is the file Foo.pm package Foo; use strict; use warnings; sub new { my $class = shift @_; print "class = $class\n"; my $self = {}; return bless $self, $class; } 1; # heres a test program using it, called foo_test.pl # #!/usr/bin/perl use strict; use warnings; use Foo; use Data::Dumper; { print "Arrow test:\n"; my $regular_foo = Foo->new(); print Dumper($regular_foo); print "\n\nColon test:\n"; my $colon_foo = Foo::new(); print Dumper($colon_foo); }
Arrow test: class = Foo $VAR1 = bless( {}, 'Foo' ); Colon test: Use of uninitialized value in concatenation (.) or string at Foo.pm li +ne 9. class = Use of uninitialized value in bless at Foo.pm line 13. Explicit blessing to '' (assuming package main) at Foo.pm line 13. $VAR1 = bless( {}, 'main' );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Foo->new() vs. new Foo()
by NetWallah (Canon) on Oct 24, 2005 at 21:36 UTC | |
by chromatic (Archbishop) on Oct 24, 2005 at 21:41 UTC | |
by BUU (Prior) on Oct 25, 2005 at 05:00 UTC |