perl help---many thanks# Programming - 葵花宝典
f*y
1 楼
The following code always output 1, i.e.,
"if (not exists($calls->{$curfunc}->{1}))" is always true. why?
I am a newbie in perl, thanks
my $calls = { };
my $curfunc;
while (<>) {
chomp;
if (/^;; Function (\S+)\s*$/) {
$curfunc = $1;
$calls->{$curfunc} = { } if ! exists($calls->{$curfunc});
}
###HERE, add a pointer to a hash table if such entry does not exists
if (not exists($calls->{$curfunc}->{1}))
{
$calls->{$curfunc}->{$1} = {};
$cal
"if (not exists($calls->{$curfunc}->{1}))" is always true. why?
I am a newbie in perl, thanks
my $calls = { };
my $curfunc;
while (<>) {
chomp;
if (/^;; Function (\S+)\s*$/) {
$curfunc = $1;
$calls->{$curfunc} = { } if ! exists($calls->{$curfunc});
}
###HERE, add a pointer to a hash table if such entry does not exists
if (not exists($calls->{$curfunc}->{1}))
{
$calls->{$curfunc}->{$1} = {};
$cal