Skip to content

Use of uninitialized value in substitution (s///) in _set_breakpont() #218

@yzazik

Description

@yzazik

Hello, I'm getting this in VSCode, interpreter throws an error here:

sub _set_breakpoint
    {
. . .
    local *dbline = "::_<$filename" if ($filename) ;
    for (my $line = $location; $line <= $location + 10 && $location < @dbline; $line++)
        {
        if ($dbline[$line] != 0)
            {
            $dbline{$line+0} =~ s/^[^\0]*/$condition/; # <-- !!! right here !!!
            return (1, undef, $line, $filename) ;
            }
        }

    return (0, "Line $location for sub $subname is not breakable.") if ($subname) ;
    return (0, "Line $location is not breakable.") ;
    }

In this line $dbline{$line+0} =~ s/^[^\0]*/$condition/; the $dbline initially is being a string scalar, accessing it as $dbline{$line+0} (with curly brackets) would make it a hash with a key equal to $line+0 and value undef, and only then the regex substitution would proceed, so interpreter is correct complaining about uninitialized value.
Is this by intent or there is a some sort of bug there or a simple typo?
Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions