[kw-pm] $1 matching question
rprice at freeshell.org
rprice at freeshell.org
Wed Jul 21 18:48:09 CDT 2004
Did it fail to assign to the value when it did not get a match rather than
assigning Undef to it?
Rick
On Wed, 21 Jul 2004, Daniel R. Allen wrote:
> 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
>
> _______________________________________________
> kw-pm mailing list
> kw-pm at mail.pm.org
> http://mail.pm.org/mailman/listinfo/kw-pm
>
More information about the kw-pm
mailing list