another doggone newbie problem:"&&" not short-circuiting like it
another doggone newbie problem:"&&" not short-circuiting like it
am 28.02.2007 16:14:29 von Deane.Rothenmaier
This is a multipart message in MIME format.
--===============1508347764==
Content-Type: multipart/alternative;
boundary="=_alternative 0053BA7386257290_="
This is a multipart message in MIME format.
--=_alternative 0053BA7386257290_=
Content-Type: text/plain; charset="us-ascii"
Gurus,
I'm not really a newbie, I have a few years of Perling, but this one's got
me stumped. I remember that "&&" is supposed to short circuit (skip B
completely in "A && B" if A is false), but in my code it won't. So what's
the deal?
($x eq 'T') && next if value_in_list( $u, @listA );
($x eq 'A') && next if value_in_list( $u, @listB );
($x eq 'B') && next if value_in_list( $u, @listC );
where value_in_list() is a sub that returns TRUE if $u is found in the
list it gets passed, and FALSE otherwise.
I've tried replacing the "eq 'X'" with "=~/X/" and that doesn't help. I
even tried replacing the "&&" with "and". No joy. I still get the sub
entered for each possible value of $x unless the sub returns TRUE on a
previous test. That is, if $x is 'B', the sub gets entered for all three
possibilities, T, A, and B. I think this shouldn't be happening, but it
is (well, was, now I'm using a really ugly if-elsif-elsif). Any hints as
to why my && ain't workin' like it oughta?
TIA,
Deane Rothenmaier
Systems Architect
Walgreens Corp.
847-914-5150
"On two occasions I have been asked [by members of Parliament], 'Pray, Mr.
Babbage, if you put into the machine wrong figures, will the right answers
come out?' I am not able rightly to apprehend the kind of confusion of
ideas that could provoke such a question." -- Charles Babbage
--=_alternative 0053BA7386257290_=
Content-Type: text/html; charset="us-ascii"
Gurus,
I'm not really a newbie, I have a few years of Perling, but this one's got me stumped. I remember that "&&" is supposed to short circuit (skip B completely in "A && B" if A is false), but in my code it won't. So what's the deal?
<code>
($x eq 'T') && next if value_in_list( $u, @listA );
($x eq 'A') && next if value_in_list( $u, @listB );
($x eq 'B') && next if value_in_list( $u, @listC );
</code>
where value_in_list() is a sub that returns TRUE if $u is found in the list it gets passed, and FALSE otherwise.
I've tried replacing the "eq 'X'" with "=~/X/" and that doesn't help. I even tried replacing the "&&" with "and". No joy. I still get the sub entered for each possible value of $x unless the sub returns TRUE on a previous test. That is, if $x is 'B', the sub gets entered for all three possibilities, T, A, and B. I think this shouldn't be happening, but it is (well, was, now I'm using a really ugly if-elsif-elsif). Any hints as to why my && ain't workin' like it oughta?
TIA,
Deane Rothenmaier
Systems Architect
Walgreens Corp.
847-914-5150
"On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question." -- Charles Babbage
--=_alternative 0053BA7386257290_=--
--===============1508347764==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1508347764==--
RE: another doggone newbie problem:"&&" not short-circuiting like
am 28.02.2007 16:17:50 von eroode
Dean,
You're going to kick yourself. :-)
> ($x eq 'T') && next if value_in_list( $u, @listA );
This means exactly:
if (value_in_list($u, @listA))
{
($x eq 'T') && next;
}
Eric
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: another doggone newbie problem:"&&" not short-circuiting
am 28.02.2007 16:37:55 von Deane.Rothenmaier
This is a multipart message in MIME format.
--===============0472977072==
Content-Type: multipart/alternative;
boundary="=_alternative 0055E03506257290_="
This is a multipart message in MIME format.
--=_alternative 0055E03506257290_=
Content-Type: text/plain; charset="us-ascii"
>You're going to kick yourself. :-)
>
>> ($x eq 'T') && next if value_in_list( $u, @listA );
>
>This means exactly:
>
> if (value_in_list($u, @listA))
> {
> ($x eq 'T') && next;
> }
Please to be considering my, er, self, properly kicked! No wonder it
didn't work...
Thanks, nonetheless, for the clarification. Um, by any chance would there
be a way to make it DWIM?
Deane Rothenmaier
Systems Architect
Walgreens Corp.
847-914-5150
"On two occasions I have been asked [by members of Parliament], 'Pray, Mr.
Babbage, if you put into the machine wrong figures, will the right answers
come out?' I am not able rightly to apprehend the kind of confusion of
ideas that could provoke such a question." -- Charles Babbage
--=_alternative 0055E03506257290_=
Content-Type: text/html; charset="us-ascii"
>You're going to kick yourself. :-)
>
>> ($x eq 'T') && next if value_in_list( $u, @listA );
>
>This means exactly:
>
> if (value_in_list($u, @listA))
> {
> ($x eq 'T') && next;
> }
Please to be considering my, er, self, properly kicked! No wonder it didn't work...
Thanks, nonetheless, for the clarification. Um, by any chance would there be a way to make it DWIM?
Deane Rothenmaier
Systems Architect
Walgreens Corp.
847-914-5150
"On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question." -- Charles Babbage
--=_alternative 0055E03506257290_=--
--===============0472977072==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============0472977072==--
RE: another doggone newbie problem:"&&" not
am 28.02.2007 16:47:50 von Brian Raven
From: activeperl-bounces@listserv.ActiveState.com
[mailto:activeperl-bounces@listserv.ActiveState.com] On Behalf Of
Deane.Rothenmaier@walgreens.com
Sent: 28 February 2007 15:38
To: Roode, Eric
Cc: activeperl-bounces@listserv.ActiveState.com;
activeperl@listserv.ActiveState.com
Subject: RE: another doggone newbie problem:"&&" not
short-circuitinglike itoughta
> >You're going to kick yourself. :-)
> > =
> >> ($x eq 'T') && next if value_in_list( $u, @listA ); =
> >
> >This means exactly:
> > =
> > if (value_in_list($u, @listA))
> > {
> > ($x eq 'T') && next;
> > }
> =
> =
> Please to be considering my, er, self, properly kicked! No wonder it
didn't work... =
> =
> Thanks, nonetheless, for the clarification. Um, by any chance would
there be a way to make it DWIM? =
It's not absolutly clear exactly WYM, but my first guess would be
something like:
($x eq 'T') && value_in_list( $u, @listA ) && next;
Or:
next if ($x eq 'T') && value_in_list( $u, @listA );
HTH
-- =
Brian Raven =
==================== =====3D=
================
Atos Euronext Market Solutions Disclaimer
==================== =====3D=
================
The information contained in this e-mail is confidential and solely for the=
intended addressee(s). Unauthorised reproduction, disclosure, modification=
, and/or distribution of this email may be unlawful.
If you have received this email in error, please notify the sender immediat=
ely and delete it from your system. The views expressed in this message do =
not necessarily reflect those of Atos Euronext Market Solutions.
Atos Euronext Market Solutions Limited - Registered in England & Wales with=
registration no. 3962327. Registered office address at 25 Bank Street Lon=
don E14 5NQ United Kingdom. =
Atos Euronext Market Solutions SAS - Registered in France with registration=
no. 425 100 294. Registered office address at 6/8 Boulevard Haussmann 750=
09 Paris France.
L'information contenue dans cet e-mail est confidentielle et uniquement des=
tinee a la (aux) personnes a laquelle (auxquelle(s)) elle est adressee. Tou=
te copie, publication ou diffusion de cet email est interdite. Si cet e-mai=
l vous parvient par erreur, nous vous prions de bien vouloir prevenir l'exp=
editeur immediatement et d'effacer le e-mail et annexes jointes de votre sy=
steme. Le contenu de ce message electronique ne represente pas necessaireme=
nt la position ou le point de vue d'Atos Euronext Market Solutions.
Atos Euronext Market Solutions Limited Soci=E9t=E9 de droit anglais, enregi=
str=E9e au Royaume Uni sous le num=E9ro 3962327, dont le si=E8ge social se =
situe 25 Bank Street E14 5NQ Londres Royaume Uni.
Atos Euronext Market Solutions SAS, soci=E9t=E9 par actions simplifi=E9e, e=
nregistr=E9 au registre dui commerce et des soci=E9t=E9s sous le num=E9ro 4=
25 100 294 RCS Paris et dont le si=E8ge social se situe 6/8 Boulevard Hauss=
mann 75009 Paris France.
==================== =====3D=
================
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: another doggone newbie problem:"&&" not short-circuiting
am 28.02.2007 16:53:39 von Deane.Rothenmaier
This is a multipart message in MIME format.
--===============0007995092==
Content-Type: multipart/alternative;
boundary="=_alternative 005750DD06257290_="
This is a multipart message in MIME format.
--=_alternative 005750DD06257290_=
Content-Type: text/plain; charset="us-ascii"
Found it. Just reverse the order of the tests. Instead of
($x eq 'T') && next if value_in_list( $u, @listA );
use
value_in_list( $u, @listA ) && next if ($x eq 'T');
Can you say "counter-intuitive"???
Thanks for making me turn up the power dial on the ol' thinking cap!
Deane Rothenmaier
Systems Architect
Walgreens Corp.
847-914-5150
"On two occasions I have been asked [by members of Parliament], 'Pray, Mr.
Babbage, if you put into the machine wrong figures, will the right answers
come out?' I am not able rightly to apprehend the kind of confusion of
ideas that could provoke such a question." -- Charles Babbage
--=_alternative 005750DD06257290_=
Content-Type: text/html; charset="us-ascii"
Found it. Just reverse the order of the tests. Instead of
($x eq 'T') && next if value_in_list( $u, @listA );
use
value_in_list( $u, @listA ) && next if ($x eq 'T');
Can you say "counter-intuitive"???
Thanks for making me turn up the power dial on the ol' thinking cap!
Deane Rothenmaier
Systems Architect
Walgreens Corp.
847-914-5150
"On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question." -- Charles Babbage
--=_alternative 005750DD06257290_=--
--===============0007995092==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============0007995092==--
RE: another doggone newbie problem:"&&" not short-circuiting like it
am 28.02.2007 16:55:24 von Deane.Rothenmaier
This is a multipart message in MIME format.
--===============0804370292==
Content-Type: multipart/alternative;
boundary="=_alternative 005779C606257290_="
This is a multipart message in MIME format.
--=_alternative 005779C606257290_=
Content-Type: text/plain; charset="us-ascii"
Aha! Another avenue to explore. And much clearer than my second repost.
THANKS!
Deane Rothenmaier
Systems Architect
Walgreens Corp.
847-914-5150
"On two occasions I have been asked [by members of Parliament], 'Pray, Mr.
Babbage, if you put into the machine wrong figures, will the right answers
come out?' I am not able rightly to apprehend the kind of confusion of
ideas that could provoke such a question." -- Charles Babbage
--=_alternative 005779C606257290_=
Content-Type: text/html; charset="us-ascii"
Aha! Another avenue to explore. And much clearer than my second repost. THANKS!
Deane Rothenmaier
Systems Architect
Walgreens Corp.
847-914-5150
"On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question." -- Charles Babbage
--=_alternative 005779C606257290_=--
--===============0804370292==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============0804370292==--