Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Set Notation Handling

by tradez (Pilgrim)
on Mar 28, 2005 at 22:28 UTC ( [id://442983]=note: print w/replies, xml ) Need Help??


in reply to Re: Set Notation Handling
in thread Set Notation Handling

This is really a great module, but what would be the simplest way to just say do this:
$set_spec = '1-4,6,9,12-18'; if ($value IS IN $set_spec){ print "$value is valid\n"; }else{ print "$value is invalid\n"; }


Tradez
"Every official that come in
Cripples us leaves us maimed
Silent and tamed
And with our flesh and bones
He builds his homes"

- Zach de la Rocha

Replies are listed 'Best First'.
Re^3: Set Notation Handling
by tall_man (Parson) on Mar 28, 2005 at 23:37 UTC
    Member testing is included in Set::IntSpan. Try this.
    use strict; use Set::IntSpan; + my $set = new Set::IntSpan('1-4,6,9,12-18'); testvalue(3, $set); testvalue(7, $set); + sub testvalue { my $value = shift; my $set = shift; if (member $set $value){ print "$value is valid\n"; }else{ print "$value is invalid\n"; } }
      That works perfectly! Thank you sooo much for your help!


      Tradez
      "Every official that come in
      Cripples us leaves us maimed
      Silent and tamed
      And with our flesh and bones
      He builds his homes"

      - Zach de la Rocha

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://442983]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found