Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: CGI -Perl problem

by thatguy (Parson)
on Dec 17, 2002 at 18:08 UTC ( #220600=note: print w/replies, xml ) Need Help??


in reply to Validating ISBN numbers?

It depends on what your requirements for validation are. If you only want a ten digit number,
my $data_in="ISBN 90-70002-34-5"; $data_in=~ s/^ISBN//; $data_in=~ s/ /-/g; $data_in=~ s/-//g; my @isbn=split('', $data_in); my $count=scalar @isbn; unless (($count eq 10) && (!($count=~ m/[a-z]/i))){ warn "not enough digits in ISBN: $count instead of 10\n"; }
Now, if you are checking against a database to validate, it depends on the format of the ISBN that is stored. If it's space or hyphen delimited you can:
# data from the database you are checking against my $data_in="90 70002 34 5"; # inputed data my $check_data="ISBN 90-70002-34-5"; $check_data=~ s/^ISBN//; $check_data=~ s/-/ /g; $check_data=~ s/^ //; unless (($data_in eq $check_data) && (!($count=~ m/[a-z]/i))){{ die "failure: data in does not match db record\n"; }
Of course it all depends on how you want to validate. If you have access to a database of ISBNs and you can validate GroupID, Publisher prefix, and so on then validate against it. Other wise, the best you can hope for is that it's just 10 digits.

-phill

Ahh the power of PerlMonks.. I stopped to grab some animal cookies and suddenly there are seven replies

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://220600]
help
Chatterbox?
[perldigious]: As long as you are a good "boy scout" stevieb, more power to you... but I like my Jeep, and don't like the idea of rolling it or crashing it in to anything. :-)
[thezip]: Me, not as much.
[perldigious]: Mine too thezip, especially my German Shepherd. He looks like he is about to die of heat exhaustion all summer, so he goes nuts when winter comes and he can play in the snow.
[stevieb]: my main off-road vehicle nowadays is a strengthened mercedes ML320. I'm very hard on it, but I've never had any real issues at all (I love how small and light it is, and it has a very, very good centre of gravity for how I roll)
[perldigious]: "for how I roll"... ahhh, I see what you did there stevieb.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (13)
As of 2016-12-06 16:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (112 votes). Check out past polls.