more than one statement in a post perlish condition

A

Alexander Jack

Dear community ,
I wanted to know that how do I give more than one statement in a post
perlish condition ,

for ex:
print "YES" if ( $yes eq "yes");


I want to change the value of $yes if it is true that means it should
execute after
print statement.

Thanks in Advance
 
P

Peter Makholm

Alexander Jack said:
Dear community ,
I wanted to know that how do I give more than one statement in a post
perlish condition ,

for ex:
print "YES" if ( $yes eq "yes");

For more than one simple statement I would almost always use a real if
block

if ($yes eq "yes") {
print "YES";
$yes = "no;
}

If you for some reason want to hide the condition as a statement
modifier you could use a do block:

do {
print "YES";
$yes = "no";
} if $yes eq "yes";

It is possible to do something like

print("YES"), $yes = "no" if $yes eq "yes";
(print "YES"), $yes = "no" if $yes eq "yes";
print "YES" and $yes = "no" if $yse eq "yes";

but I consider all of them less readable than the block forms and at
least the last example isn't obvious for people not quite used to perl
precedence rules.

//Makholm.
 
P

Peter Makholm

Ben Morrow said:
The last example is also Wrong, in that print can fail. It's not common,

Correct, I should have mentioned that the last one wasn't semantically
equivalent with the others.

//Makholm
 
J

Justin C

Dear community ,
I wanted to know that how do I give more than one statement in a post
perlish condition ,

for ex:
print "YES" if ( $yes eq "yes");

I want to change the value of $yes if it is true that means it should
execute after
print statement.

print "yes" if (($yes eq "yes") && ($yes = 'no'));


Justin.
 
U

Uri Guttman

JC> print "yes" if (($yes eq "yes") && ($yes = 'no'));

it is nice to be helpful but better to be correct. the latter is = which
is very wrong in two ways: it is an assignment and not a comparison and
it is also numeric (assuming you meant ==) and not a string
comparison. then the logic is also tortured. why would you check for
'yes' and ALSO 'no'. it can't be both. next the OP wanted multiple
statements with a single modifier, not multiple booleans in one
modifier. finally all the parens aren't needed and are noisy.

uri
 
W

Willem

Uri Guttman wrote:
)
) >> I want to change the value of $yes if it is true that means it should
) >> execute after
) >> print statement.
)
) JC> print "yes" if (($yes eq "yes") && ($yes = 'no'));
)
) it is nice to be helpful but better to be correct. the latter is = which
) is very wrong in two ways: it is an assignment and not a comparison and
) it is also numeric (assuming you meant ==) and not a string
) comparison. then the logic is also tortured. why would you check for
) 'yes' and ALSO 'no'. it can't be both. next the OP wanted multiple
) statements with a single modifier, not multiple booleans in one
) modifier. finally all the parens aren't needed and are noisy.

*whoosh*


SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
 
S

Scott Bryce

Uri said:
JC> print "yes" if (($yes eq "yes") && ($yes = 'no'));

it is nice to be helpful but better to be correct. the latter is =
which is very wrong in two ways: it is an assignment and not a
comparison and it is also numeric (assuming you meant ==) and not a
string comparison. then the logic is also tortured. why would you
check for 'yes' and ALSO 'no'. it can't be both. next the OP wanted
multiple statements with a single modifier, not multiple booleans in
one modifier. finally all the parens aren't needed and are noisy.


Did I miss something? What the OP wants to do is evaluate $yes. If $yes
contains 'yes', then print it and change its value.

The line if code JC provided does that. If $yes evaluates to 'yes' then
$yes is set to 'no'. Since setting $yes to 'no' evaluates to TRUE, the
print statement is executed.




use strict;
use warnings;

my $yes = 'yes';

print 'yes' if (($yes eq 'yes') && ($yes = 'no'));

print "\nYes now equals $yes";
 
U

Uri Guttman

SB> Did I miss something? What the OP wants to do is evaluate $yes. If $yes
SB> contains 'yes', then print it and change its value.

SB> The line if code JC provided does that. If $yes evaluates to 'yes' then
SB> $yes is set to 'no'. Since setting $yes to 'no' evaluates to TRUE, the
SB> print statement is executed.

not what i read but i could be wrong. in any case (and regardless of the
correctness of the above code) it is horrible. using assignment INSIDE a
conditional of a modifier is nuts. it should never be done especially in
a compound boolean. it LOOKS like a bug and will always be read as one.

uri
 
N

Nathan Keel

Willem said:
Uri Guttman wrote:
)
) >> I want to change the value of $yes if it is true that means it
should
) >> execute after
) >> print statement.
)
) JC> print "yes" if (($yes eq "yes") && ($yes = 'no'));
)
) it is nice to be helpful but better to be correct. the latter is =
which ) is very wrong in two ways: it is an assignment and not a
comparison and ) it is also numeric (assuming you meant ==) and not a
string ) comparison. then the logic is also tortured. why would you
check for ) 'yes' and ALSO 'no'. it can't be both. next the OP wanted
multiple ) statements with a single modifier, not multiple booleans in
one ) modifier. finally all the parens aren't needed and are noisy.

*whoosh*


SaSW, Willem

LOL!
 
P

Peter Makholm

Justin C said:
print "yes" if (($yes eq "yes") && ($yes = 'no'));

As Uri has explained this is very prone to mis-readings and is thus
unmaintainable. If we go by the example you solution works, but the
assignment happens *before* the print statement, which could be argued
to be wrong according to "the spec".

//Makholm
 
N

Nathan Keel

Peter said:
As Uri has explained this is very prone to mis-readings

I think it's more that Uri is proe to mis-reading. Anyway, that was one
example by one person. If you prefer it to read different (nothing
wrong with that, maybe there's everything right with that), then feel
free to make the alternative suggestion. Saying someone's wrong
because you're too excited about arguing with people on the usenet
group (which is often what uri does), is pointless.
 
U

Uri Guttman

NK> I think it's more that Uri is proe to mis-reading. Anyway, that was one

proe? do i read that correctly? anyhow, your experience here is nothing
to shout about.

NK> example by one person. If you prefer it to read different (nothing
NK> wrong with that, maybe there's everything right with that), then feel
NK> free to make the alternative suggestion. Saying someone's wrong
NK> because you're too excited about arguing with people on the usenet
NK> group (which is often what uri does), is pointless.

pointless is your middle name. you have yet to actually comment on the
code or ideas in this thread. how about sticking to perl and not some
inane comments about me? but you won't because you are obsessed with
me. your issue not mine.

and my last comment still stands. the last example was horrible code
regardless of its logical correctness or not. you don't mix assignments
in a complex boolean. if you don't get that then you shouldn't be
commenting on other people's code.

uri
 
C

Charlton Wilbur

JC> print "yes" if (($yes eq "yes") && ($yes = 'no'));

While technically correct, this is a really stupid construction because
it's so prone to misreading (as uri so aptly demonstrated). Why
not just say what you mean?

if ($yes eq 'yes')
{
print $yes;
$yes = 'no';
}

What benefit do you get from making it so confusing to parse and
understand?

Charlton
 
N

Nathan Keel

Uri said:
NK> I think it's more that Uri is proe to mis-reading. Anyway, that
was one

proe? do i read that correctly? anyhow, your experience here is
nothing to shout about.

Believe it or not, the fact you're an arrogant prick to everyone here
and I didn't put up with your BS, doesn't actually mean squat. I know
that's hard for you to accept. Anyway, you said you killfiled me, but
as usual, you never did, because you're an arrogant fraud. Now, ****
off already.
NK> example by one person. If you prefer it to read different
(nothing NK> wrong with that, maybe there's everything right with
that), then feel
NK> free to make the alternative suggestion. Saying someone's wrong
NK> because you're too excited about arguing with people on the
usenet NK> group (which is often what uri does), is pointless.

pointless is your middle name. you have yet to actually comment on the
code or ideas in this thread. how about sticking to perl and not some
inane comments about me? but you won't because you are obsessed with
me. your issue not mine.

Oh yeah, it's proof that I'm obsessed with you, all because I let the
poster know how you are (and you *are* like that). Get over yourself.
Maybe if you did more than insult people, your misunderstood responses
would be better received. But, don't actually dare and be a better
person by my account!
and my last comment still stands. the last example was horrible code
regardless of its logical correctness or not. you don't mix
assignments in a complex boolean. if you don't get that then you
shouldn't be commenting on other people's code.

uri
nal cake

Who gives a damn what you think? It's easily understood, the poster
offered help. They were right, and the subject went right over your
head because you were too busy intent on insulting someone (as usual).
Believe it or not, I don't agree it was the most logical to look at
either, but it wasn't that big of a deal. If you don't get that
everyone doesn't agree with your extreme, arrogant and insulting views,
to where you think they have no business expressing their opinion, then
you direly need to get a clue. Anyway, how about you go back to
"killfiling" me, like you said you did (which you clearly never did).
And, don't worry, I've not been mentioning you other than yesterday,
and because you suck. I won't be spending time in an effort to bother
(expose) you.
 
U

Uri Guttman

NK> Believe it or not, the fact you're an arrogant prick to everyone here
NK> and I didn't put up with your BS, doesn't actually mean squat. I know
NK> that's hard for you to accept. Anyway, you said you killfiled me, but
NK> as usual, you never did, because you're an arrogant fraud. Now, ****
NK> off already.

fraud? are you accusing me of fraud? a perl ponzi scheme? please pay up
and i will repay your perl with 20% better code. hell, in your case 50%
is guaranteed!

NK> Oh yeah, it's proof that I'm obsessed with you, all because I let the
NK> poster know how you are (and you *are* like that). Get over yourself.
NK> Maybe if you did more than insult people, your misunderstood responses
NK> would be better received. But, don't actually dare and be a better
NK> person by my account!

i don't insult people, just non-entities. or those who bitch and don't
actually help with perl. you fit both categories just fine.
NK> nal cake

wow. such witlessness. such originality. did your father help you out
with that? does making up stupid names make you feel better? this is
what i mean by obsessed. you resort to that same silly nickname each
time. the depth of your wit is as shallow as your perl skills. (now THAT
is an insult).

NK> Who gives a damn what you think? It's easily understood, the
NK> poster offered help. They were right, and the subject went right
NK> over your head because you were too busy intent on insulting
NK> someone (as usual). Believe it or not, I don't agree it was the
NK> most logical to look at either, but it wasn't that big of a deal.
NK> If you don't get that everyone doesn't agree with your extreme,
NK> arrogant and insulting views, to where you think they have no
NK> business expressing their opinion, then you direly need to get a
NK> clue. Anyway, how about you go back to "killfiling" me, like you
NK> said you did (which you clearly never did). And, don't worry,
NK> I've not been mentioning you other than yesterday, and because you
NK> suck. I won't be spending time in an effort to bother (expose)
NK> you.

and the code sucked. others have agreed. regardless of its
correctness. you don't get that and you won't. you are blinded against
all i could ever say. more like the birthers and the town-hall loonies,
you rant about me but never say anything coherent. i will not let you
stop my perl health reform progress.

now go learn python and annoy them.

uri
 
N

Nathan Keel

Uri said:
NK> Believe it or not, the fact you're an arrogant prick to everyone
here
NK> and I didn't put up with your BS, doesn't actually mean squat.
I know
NK> that's hard for you to accept. Anyway, you said you killfiled
me, but
NK> as usual, you never did, because you're an arrogant fraud. Now,
**** NK> off already.

fraud? are you accusing me of fraud? a perl ponzi scheme? please pay
up and i will repay your perl with 20% better code. hell, in your case
50% is guaranteed!

Yes, you're a fraud, I didn't say scammer. A fraud is someone that acts
like something for some benefit, and acts a different way in other
situations. Whatever you think makes you look smarter, regardless of
how much of a worthless prick you are about stuff. Who cares what
skills you have if you're just a dick to everyone ALL OF THE TIME!?
Your arrogance toward anyone that doesn't put up with your bullshit is
boring.
NK> Oh yeah, it's proof that I'm obsessed with you, all because I
let the
NK> poster know how you are (and you *are* like that). Get over
yourself. NK> Maybe if you did more than insult people, your
misunderstood responses
NK> would be better received. But, don't actually dare and be a
better NK> person by my account!

i don't insult people, just non-entities. or those who bitch and don't
actually help with perl. you fit both categories just fine.

You're just acting like a little bitch because you think you can
cyber-bully people around and you react poorly to anyone that tells you
how it is. You're pathetic. And, actually, you are rude, arrogant and
a prick to people that didn't deserve it. You can act like I deserve
it because I'm putting you in your place, but those other people
didn't. With you, it doesn't seem to matter, people are deserving of
your arrogant abuse no matter what, so I may as well put you in your
place.
NK> nal cake

wow. such witlessness. such originality.

Thank you.
did your father help you out
with that?

Yes. My entire family was there. It was a big event. You ARE that
important.
does making up stupid names make you feel better?
Sometimes.

this is
what i mean by obsessed.

You mean me calling you by a name when you're being a worthless prick,
is somehow proof that I'm obsessed? I won't question where you get
your degree or rationalization to qualify such claims, because I know
you believe in your own mind that you're that special and I don't want
to hurt your fragile feelings.
you resort to that same silly nickname each
time.

Yes, I do.
the depth of your wit is as shallow as your perl skills. (now
THAT is an insult).

That actually wasn't a very good insult, especially since I'm confident
of myself and my skills (though I don't pretend to know everything, I
don't randomly and baselessly treat fellow civil group members like the
worthless piles of shit you do... and that you *are*) Anyway, I'm
talking about how you treat everyone in general, not me. I realize me
putting you in your place is something you'd react poorly to (of course
you would, I would, too. So, I don't fault you for that, but you care
not for the "why", you just see a chance to self-boast). You honestly
do not impress me, not in the least.
NK> Who gives a damn what you think? It's easily understood, the
NK> poster offered help. They were right, and the subject went
right NK> over your head because you were too busy intent on
insulting
NK> someone (as usual). Believe it or not, I don't agree it was the
NK> most logical to look at either, but it wasn't that big of a
deal. NK> If you don't get that everyone doesn't agree with your
extreme, NK> arrogant and insulting views, to where you think they
have no NK> business expressing their opinion, then you direly need
to get a
NK> clue. Anyway, how about you go back to "killfiling" me, like
you
NK> said you did (which you clearly never did). And, don't worry,
NK> I've not been mentioning you other than yesterday, and because
you
NK> suck. I won't be spending time in an effort to bother (expose)
NK> you.

and the code sucked. others have agreed. regardless of its
correctness.

Yet, somehow, this all came about because the OP's question went zooming
right over your thick head. Odd...
you don't get that and you won't.

In fact, I do get it. And, in fact, I do "get" that it's better
written. I never disagreed with that. I disagree with how you choose
to interact with people, because you suck.
you are blinded against
all i could ever say.

Not really, I realize you have Perl skills. I'm just saying you're a
fucking dick.
more like the birthers and the town-hall
loonies, you rant about me but never say anything coherent.

Believe it or not, just saying I'm not being coherent because I'm
pointing out valid points that embarrass you (as you should well be),
doesn't actually make it so. Granted, I realize you think you're
important enough to just randomly make wild accusations and believe
that's all the proof you need to make it true, but you're just not that
important. Everything I have said is factual and offers perfect
clarity. Perhaps you disagree and chose to lie or defend yourself (who
wouldn't?), but to claim it's incoherent in response just shows how
desperate, foolish and self conscious you are.
i will not
let you stop my perl health reform progress.

I am exposing your shitty attitude, I did not put into question your
Perl skills.
now go learn python and annoy them.

Uh huh.
 
N

Nathan Keel

Tad said:
Making obviously false statements does not help support your position.

You intentionally neglecting and defending your co-troll-cohort and
auto-siding on issues doesn't help support your position.
Ad hominem attacks do not help support your position either.

Then again, nothing would make any difference to you anyway, as is also
proven, so who fuckin' cares?
Get control of yourself man.

I'm under control. Believe it or not, people not tolerating your
insolence isn't an indication of an emotional problem. I know that's
difficult for arrogant people to accept.

I leave you with a South Park quote that will sum it up: “Your
ego has made you believe things happen differently,†Cartman said. “You
have such a huge ego you do these mental gymnastics to make yourself a
part of things ... now I realize that some people just have egos that
are so out of whack that no matter what people tell them they can’t
accept the truth of who they are.â€

Truly, there are people out there that applies to. I have a sense of
humor and decency, no one offline thinks anything but good things about
me. Sure, I tend to care less online, as you do, about how I interact
with people, so I tell you how it is. You can use that as a basis to
claim I am the one with the problem, but FFS, do you not own a mirror,
or are you truly that delusional? In all, I'm well under control, and
I chose to aggressively respond to arrogant pricks online. Of course
it's not necessary, but I'd not feel right with letting jerks just take
over and run the place. Yes, I realize the irony that you must feel
about me saying that, and I know you and uri are both convinced
everyone else is the jerk and you guys have some inalienable right to
tell someone off on usenet and so on. Big yawn.

You really should watch the "FishSticks" full episode of South Park and
consider yourself at least a little bit Cartman and a little bit Kanye.
I know you'll never change, but I'll also never cease putting you in
your place. I don't give a **** if you two have Perl skills and offer
help now and again, because it's far outweighed by the arrogance you
two displat more than not. It's too bad, because if you two didn't
suck so bad at being people, you'd have a lot more going for you.
Yeah, yeah, again, I realize how me saying this must sound to you, and
you can convince yourself that it's everyone else with the problem and
not you. Me, I'm willing to concede I'm not perfect, and I don't go
out of my way to be rude, insulting and arrogant to random people
online (or offline). Give me a reason, I will, but otherwise I will
not. It's a pretty simple and easy thing to live by. I hope you see
the way you are, but I guess you can't help it (referencing the Cartman
quote above). I'll leave you with "zoom!".
 
N

Nathan Keel

Tad said:

Thanks for side stepping all of the other valid points I had made, just
to repeat what you accused me of previously. In the end, the problem
is that there is a lot of unnecessary arrogance and rudeness on usenet
(it's not just you two). If someone gives a reason, while it's all
pretty petty anyway, at least that's understandable. But, to just have
this shitty attitude in general to everyone, I think it's a bit
strange. Indeed, I believe people like you are out of control, rather
than the people that don't tolerate it, but I'm sure we can both
"control" ourselves enough to just ignore all of the bullshit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top