Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Fellow Monks,

I've tried super search on this and came up empty.

I'm trying to do a match of data that is non-consecutive as the code below shows. This is to figure out the UPS zone for shipping. I realize that Business::UPS does this but I'd rather hard code the zones as opposed to doing the LWP lookup each time as the module does.

use strict; # Zone 8 my $z8 = "10-374,376-379,382-385,388-499,530-534,541-543,618,619,700-7 +04,707-709"; my $num = "34"; print "Found it!\n" if $num =~/[$z8]/;

When run, the above code gives me an error:

Invalid [] range "6-3" in regex; marked by <-- HERE in m/[10-374,376-3 + <-- HERE 79,382-385,388-499,530-534,541-543,618,619,700-704,707-709] +/

but I'm not sure how to match it against the range I've specified.

I understand that it's seeing the 6-3 and thinking that it's already tried to match against 10-374, so how can I get the regex to match against the entire range?

Useless trivia: In the 2004 Las Vegas phone book there are approximately 28 pages of ads for massage, but almost 200 for lawyers.

In reply to Matching data against non-consecutive range by Popcorn Dave

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-18 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found