[kw-pm] $1 matching question
Daniel R. Allen
da at coder.com
Wed Jul 21 14:55:29 CDT 2004
I've got a regex question that I'm probably just being stupid about:
bash% echo -e "9 \n \n 2" | perl -ne'/(\d+)/; print "$1 ";'
has the following result:
9 9 2
Shouldn't it be '9 2' ? And the result is the same with:
bash% echo -e "9 \n \n 2" | perl -ne'$z = ""; /(\d+)/; $z = $1; print "$z
" if $z;'
Which means $1 is actively being assigned to, when there isn't a match!
deparse tells me:
bash% perl -MO=Deparse -ne'/(\d+)/; print "$1 ";'
LINE: while (defined($_ = <ARGV>)) {
/(\d+)/;
print "$1 ";
}
...which looks just like I'd expect. Maybe I just took a stupid pill this
morning.
-Daniel
--
"Use a different web browser. There are a number of significant vulnerabilit-
ies in technologies relating to the [Microsoft] IE domain/zone security model,
the DHTML object model, MIME type determination, and ActiveX." - US CERT (US
Computer Emergency Readiness Team) - http://www.kb.cert.org/vuls/id/713878
More information about the kw-pm
mailing list