Others have mentioned quoting the - so you don't get a false range. What is happening is this (I realize I am probably beating a dead horse by this time), anything within the
[] is part of a character class and so if you put something like
[a-z], the regex engine will interpret this as anything from a to z (e.g, a,b,c,d,e,f,g), in order to save the progammer some work (i.e. having to type each and ever character). So what you end up needing to do is escape the "-" if you want it as part of your character class, so it is not misiterpreted as a range between the character on its left and the one on its right. Alternatively, if the "-" is the first or last thing in your square brackets then it will also be taken as part of that class, as the regex engine realizes that its position cannot possibly be interpreted as part of a class range. for example:
$params{city} =~ /^[-\w'\.\*]*$/ and do_stuff() ;
or
$params{city} =~ /^[\w'\.\*-]*$/ and do_stuff() ;
-enlil
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.