(I deleted my old question and repeated here)
I tried the some thing like the following:
# MyPakage implemets 'new'
# use MyPakage; this line is commented
my $PakageName = "MyPakage";
eval "use $PakageName";
print "eval(use): $@" if $@; # this line prints nothing
my $var = eval "new $PakageName";
print "eval(new): $@" if $@; # this too prints nothing
my $var2 = $var->FunctionInMyPakage;
I am getting an error "can not call FunctionInMyPakage with an undefined value..."
What is the problem with the code?