> >> The suggestion of:
> >>
> >> if($something =~ /^(string0|string1|string2)$/)
> >>
> >> is not equivalent to your original condition. It's also likely to be
> >> inefficient.
> >
> > I get 1 min 15.983sec for "normal" three condition if, and 52.305sse for
> > a regex approach. My
> > test c
PM
> To: Perl Beginners
> Subject: RE: evaluating multiple conditions
>
> > It's my understanding that the difference between
> >
> > &some_func;
> >
> > and
> >
> > some_func();
> >
> > is that the '&
> It's my understanding that the difference between
>
> &some_func;
>
> and
>
> some_func();
>
> is that the '&' invocation passes the original contents of @_ into
> some_func, whereas the '()' invocation has an empty @_ in some_func. In the
> first instance, some_func has access to the argum
> This code doesn't need to be fixed. For style, I would remove the
> inner parens (unnecessary) and change the function calls to
> do_something() instead of the (old-style) &do_something.
Is changing the function calls just a matter of style, or is
there a more important reason to do it?
On Tuesday, April 23, 2002, at 03:05 PM, Jonathan E. Paton wrote:
>>> Is there a better way to simplify the syntax when testing for multiple
>>> conditions?
>>
>> Your original code is the proper way to do it. All the other solutions
>> proffered are inferior, IMO.
>
> Use 'or' and 'and' to rem
> > Is there a better way to simplify the syntax when testing for multiple
> > conditions?
>
> Your original code is the proper way to do it. All the other solutions
> proffered are inferior, IMO.
Use 'or' and 'and' to remove clutter, they have different precedance and
are often useful in this c
string.
-Original Message-
From: Bob Showalter [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 2:25 PM
To: 'Timothy Johnson'; Perl Beginners
Subject: RE: evaluating multiple conditions
> -Original Message-
> From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
>
> -Original Message-
> From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, April 23, 2002 5:11 PM
> To: 'Bob Showalter'; 'Shaun Fryer'; Perl Beginners
> Subject: RE: evaluating multiple conditions
>
>
>
> Oops. I misread th
, April 23, 2002 1:54 PM
To: 'Shaun Fryer'; Perl Beginners
Subject: RE: evaluating multiple conditions
> -Original Message-
> From: Shaun Fryer [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, April 23, 2002 4:15 PM
> To: Perl Beginners
> Subject: evaluating multiple condi
> -Original Message-
> From: Shaun Fryer [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, April 23, 2002 4:15 PM
> To: Perl Beginners
> Subject: evaluating multiple conditions
>
>
> Is there a simple way to evaluate multiple conditions in an if or
> unless stat
Shaun,
You would want to use a switch (sometimes called "case") statementtry
something like this
MYSWITCH: for ($something) {
/string0/&& do {
&do_something;
last MYSWITCH;
};
/string1/&& do {
&do_something;
* Shaun Fryer <[EMAIL PROTECTED]> [2002-04-23 22:15 +0200]:
> Is there a simple way to evaluate multiple conditions in an if or
> unless statement?
perldoc -q 'How do I create a switch or case statement?'
--
Johannes Franken
Professional unix/network development
mailto:[EMAIL PROTECTED]
http:
How about this?
if($something =~ /^(string0|string1|string2)$/){
-Original Message-
From: Shaun Fryer [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 1:15 PM
To: Perl Beginners
Subject: evaluating multiple conditions
Is there a simple way to evaluate multiple conditions in
Is there a simple way to evaluate multiple conditions in an if or
unless statement? For example take the following very simple example.
if (($something eq 'string0') || ($something eq 'string1') || ($something =~
/string2/)) {
&do_something;
} else {
&do_somthing_else;
}
Being a bit of a sp
14 matches
Mail list logo