in reply to "Can't happen" bugs
Nope. require Carp can't overwrite a different scope's $1. Even if (grep { /(...)/ } "abc") {print ":$1:"} has $1 undefined.this code is wrong because it uses $1 not immediately after obtaining it. require Carp is probably overwriting it (it's a global var, after all, overwritten in every capturing regexp), and indeed the error message I was getting (" is only avaliable") can be explained by a failed match or an empty capture.if (grep { /^(dualvar|set_prototype)$/ } @_ ) { require Carp; Carp::croak("$1 is only avaliable with the XS version"); }
$1 is not "global", it is automatically dynamically scoped.
The problem is that the code is using $1 outside the scope in which it was set (the grep block). The code as written will never use the $1 from the match.
I'm looking for a job.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: "Can't happen" bugs
by gaal (Parson) on Jan 16, 2007 at 19:00 UTC |