Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

OT: eregi deprecated

by ilottl (Novice)
on Mar 16, 2013 at 02:13 UTC ( #1023800=perlquestion: print w/ replies, xml ) Need Help??
ilottl has asked for the wisdom of the Perl Monks concerning the following question:

I have a site with a contact for which has..

if (email_is_valid($youremail) && !eregi("\r",$youremail) && !eregi("\n",$youremail) && $yourname != "" && $yourmessage != "" && substr(md5($user_answer),5,10) === $answer)

The site was upgraded to php 5.3 and now users received a deprecated warning....

I know its not perl, but can someone advise what the code should now be......

I have no idea and have tried to change with pregmatch directly but fail...miserably

Please help...

Comment on OT: eregi deprecated
Download Code
Re: OT: eregi deprecated
by Kenosis (Priest) on Mar 16, 2013 at 02:17 UTC
Re: OT: eregi deprecated
by tobyink (Abbot) on Mar 16, 2013 at 06:52 UTC

    eregi("\n", $youremail) becomes preg_match("/\n/", $youremail).

    But personally, I'd replace this:

    !eregi("\r",$youremail) && !eregi("\n",$youremail)

    With this, because strpos is faster than a regexp:

    strpos("\r",$youremail)===FALSE && strpos("\n",$youremail)===FALSE

    Or even (it'll probably be faster, but it's slightly obscure):

    strpos("\r",$youremail)===strpos("\n",$youremail)
    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2014-12-21 21:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (108 votes), past polls