sub new { my $class = shift; my ($uid, $root, $app) = @_; my $obj = bless {} => $class; $obj->{Root} = $root; $obj->{UserDir} = "$obj->{Root}/Usr/$uid/"; $obj->{UserAppData} = "$obj->{UserDir}$app"; return $obj; } #### sub new { my $class = shift; my ($uid, $root, $app) = @_; return bless { Root => $root, UserDir => "$root/Usr/$uid/", UserAppData => "$root/Usr/$uid/$app", } => $class; } #### c:\@Work\Perl>perl -wMstrict -le "use warnings; use strict; use Test::More 'no_plan'; use Test::NoWarnings; use Data::Dumper; package Test; sub new1 { my $class = shift; my ($uid, $root, $app) = @_; my $obj = bless {} => $class; $obj->{Root} = $root; $obj->{UserDir} = \"$obj-^>{Root}/Usr/$uid/\"; $obj->{UserAppData} = \"$obj-^>{UserDir}$app\"; return $obj; } sub new2 { my $class = shift; my ($uid, $root, $app) = @_; return bless { Root => $root, UserDir => \"$root/Usr/$uid/\", UserAppData => \"$root/Usr/$uid/$app\", } => $class; } package main; my $test1 = Test->new1('steve', '/home', 'perl'); my $test2 = Test->new2('steve', '/home', 'perl'); isa_ok $test1, 'Test', '$test1'; isa_ok $test2, 'Test', '$test2'; is_deeply $test1, $test2, qq{object data equivalent}; " ok 1 - $test1 isa Test ok 2 - $test2 isa Test ok 3 - object data equivalent ok 4 - no warnings 1..4