Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org

BBS: Re: perl question, re characters - September 13, 1998 at 04:04:08

You are here: irt.org | BBS | Re: perl question, re characters [This BBS is closed]

Posted by Jason Turner on September 13, 1998 at 04:04:08:

In Reply to: Re: perl question, re characters posted by Jason Nugent on September 12, 1998 at 10:38:17:

: : $value = "" if ( ($name eq "something") and ($value =~ /[!a-zA-Z0-9]/));

: The last character class here should be

: [^a-zA-Z0-9] (the ^ represents a negated character.

Ooops :)
I've no excuse for that mistake. I can't even say it's different for grep, sed, awk......

: $value = "" if ( $name eq "something && $value ~ /\W/ ));

: Minor points on the choices of and vs &&, and =~ vs ~

: I do believe and has a lower priority than &&. No big deal with and, but you might run into problems using its counterpart || vs or. for example:

Yep, and does have a lower priority, so if you do remove brackets, then it would be safer to use "and" instead of &&. In thise case it didn't matter which was used. "eq" and "=~" both have higher binding.

: about =~ vs ~ - the =~ operator tests and also assigns,

No it doesn't.
I think you're confusing it with $value =~ s///

The tilde alone is not a matching operator, but performs bitwise negation.

: Ah... the subtleties of perl :)

Indeed :)

: Jason

Jason
Follow-ups:

You are here: irt.org | BBS | Re: perl question, re characters [This BBS is closed]

©2018 Martin Webb