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

Re: Using IF and OR, I'm sure there is a better way

by bravenmd (Sexton)
on Dec 15, 2005 at 20:30 UTC ( [id://517072]=note: print w/replies, xml ) Need Help??


in reply to Using IF and OR, I'm sure there is a better way

try this:

if($variable =~ /1|2|3/){
...
}
  • Comment on Re: Using IF and OR, I'm sure there is a better way

Replies are listed 'Best First'.
Re^2: Using IF and OR, I'm sure there is a better way
by serf (Chaplain) on Dec 16, 2005 at 08:38 UTC
    I'd recommend trying this vs seperate elsif statements on a large file and seeing if it makes a difference.

    6 weeks ago I was optimising a process reading in a daily network syslog file of approx 1200 MB using 5.8.0 on an overworked Ultra 2 running Solaris 2.6.

    The script had been using next if (/abc|cde|fgh|/) which *looks* most concise, but I found (to my and my workmate's surprise) that replacing it with the equivalent elsif statements made it take about 30 seconds less (it had been taking >2 minutes to read the file in).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2024-04-16 10:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found