Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
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. $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. In reply to Re: "Can't happen" bugs
by ysth
|
|