does perl have boolean variables?
I can't say: #!/yadayada/perl -w use strict; $seen = true; if( $seen ) { #whatever } else { #something different } I get a bareword error, I'm using perl 5.004_04. Does perl support booleans like this, do I need to use a package? Thanks in advance -Ken The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: does perl have boolean variables?
Generally, people just use the not 0 = true, 0 or undef = false syntax. So if you just change it to: $seen = 1; if($seen){ do something... }else{ don't do it... } that would work. I think you can also declare constants for this if you really want to, but it's not that big of a pain. -Original Message- From: Ken Lehman [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 04, 2002 1:39 PM To: '[EMAIL PROTECTED]' Subject: does perl have boolean variables? I can't say: #!/yadayada/perl -w use strict; $seen = true; if( $seen ) { #whatever } else { #something different } I get a bareword error, I'm using perl 5.004_04. Does perl support booleans like this, do I need to use a package? Thanks in advance -Ken The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: does perl have boolean variables?
And, 0 is either '' -or- 0 ;) -Original Message- From: Timothy Johnson [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 04, 2002 11:43 AM To: 'Ken Lehman'; '[EMAIL PROTECTED]' Subject: RE: does perl have boolean variables? Generally, people just use the not 0 = true, 0 or undef = false syntax. So if you just change it to: $seen = 1; if($seen){ do something... }else{ don't do it... } that would work. I think you can also declare constants for this if you really want to, but it's not that big of a pain. -Original Message- From: Ken Lehman [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 04, 2002 1:39 PM To: '[EMAIL PROTECTED]' Subject: does perl have boolean variables? I can't say: #!/yadayada/perl -w use strict; $seen = true; if( $seen ) { #whatever } else { #something different } I get a bareword error, I'm using perl 5.004_04. Does perl support booleans like this, do I need to use a package? Thanks in advance -Ken The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: does perl have boolean variables?
Oh, yeah, that too. :) -Original Message- From: Beau E. Cox [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 04, 2002 1:53 PM To: Timothy Johnson; 'Ken Lehman'; [EMAIL PROTECTED] Subject: RE: does perl have boolean variables? And, 0 is either '' -or- 0 ;) -Original Message- From: Timothy Johnson [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 04, 2002 11:43 AM To: 'Ken Lehman'; '[EMAIL PROTECTED]' Subject: RE: does perl have boolean variables? Generally, people just use the not 0 = true, 0 or undef = false syntax. So if you just change it to: $seen = 1; if($seen){ do something... }else{ don't do it... } that would work. I think you can also declare constants for this if you really want to, but it's not that big of a pain. -Original Message- From: Ken Lehman [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 04, 2002 1:39 PM To: '[EMAIL PROTECTED]' Subject: does perl have boolean variables? I can't say: #!/yadayada/perl -w use strict; $seen = true; if( $seen ) { #whatever } else { #something different } I get a bareword error, I'm using perl 5.004_04. Does perl support booleans like this, do I need to use a package? Thanks in advance -Ken The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: does perl have boolean variables?
On Wed, Dec 04, 2002 at 04:38:51PM -0500, Ken Lehman wrote: > I can't say: > > #!/yadayada/perl -w > use strict; > > $seen = true; In Perl everything but "", 0, "0", undef, () is true. Use: $seen = 1; if $seen has to be true, and $seen = 0; if $seen has to be false. bye, Da.Ta. smime.p7s Description: application/pkcs7-signature
Re: does perl have boolean variables?
Ken Lehman wrote: > I can't say: > > #!/yadayada/perl -w > use strict; > > $seen = true; > > if( $seen ) > { > #whatever > } > else > { > #something different > } > if it makes you feel better, try: #!/usr/bin/perl -w use strict; use constant true => 1; use constant false => 0; my $i = true; if($i){ print "$i true\n"; }else{ print "$i false\n"; } __END__ oh, well everyone knows that already :-) david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]