in reply to Re: Immense hashes
in thread Immense hashes

It is entirely possible that the regex might not match, in which case $1 will be undef.

Or worse, the $1 variable will have the value of the previous time it matched and it will overwrite the existing entry in the hash. In this case it wil overwrite it with the same value it already had as all values of the hash are set to "blah" (which is utterly strange).

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Replies are listed 'Best First'.
Re^3: Immense hashes
by tkil (Monk) on May 28, 2004 at 16:33 UTC
    Or worse, the $1 variable will have the value of the previous time it matched and it will overwrite the existing entry in the hash.

    Hm. For some reason, I was under the impression that $1 and friends would be undef after any unsuccessful match. Oh, wow, it doesn't; gross:

    $ perl -lwe '$_="foo"; /(\w+)/ && print "match: $1"; /(\W+)/ || print "no match: $1";' match: foo no match: foo
    In this case it wil overwrite it with the same value it already had as all values of the hash are set to "blah" (which is utterly strange).

    Well, I just assumed that the original poster was using that "blah" as a placeholder for something else, for the purposes of posting. The presence of quite a few other syntactic errors makes it clear that this was not the code that actually ran...