[27309] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 9043 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 11 18:07:07 2006

Date: Sat, 11 Mar 2006 15:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 11 Mar 2006     Volume: 10 Number: 9043

Today's topics:
    Re: A Problem With GD <markem@airmail.net>
    Re: A Problem With GD <abigail@abigail.nl>
    Re: A Problem With GD <tassilo.von.parseval@rwth-aachen.de>
    Re: A Problem With GD robic0
    Re: A Problem With GD robic0
    Re: A Problem With GD robic0
    Re: A Problem With GD robic0
    Re: A Problem With GD <abigail@abigail.nl>
        Toggle flags (WAS: A Problem With GD) <jurgenex@hotmail.com>
    Re: Toggle flags (WAS: A Problem With GD) <markem@airmail.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 11 Mar 2006 10:32:41 -0600
From: Mark Manning <markem@airmail.net>
Subject: Re: A Problem With GD
Message-Id: <1215ur1bndeb911@corp.supernews.com>

Glenn Jackman wrote:
> At 2006-03-08 04:48AM, Dave Weaver <zen13097@zen.co.uk> wrote:
> 
> However, 
>     $i = -1
>     while (++$i < 10) {...
> does.
> 

What is your favorite method for implementing a toggle switch?  Mine is:

	$var = ($var + 1) % 2;



------------------------------

Date: 11 Mar 2006 17:47:56 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: A Problem With GD
Message-Id: <slrne163ac.p75.abigail@alexandra.abigail.nl>

Mark Manning (markem@airmail.net) wrote on MMMMDLXXV September MCMXCIII
in <URL:news:1215ur1bndeb911@corp.supernews.com>:
<>  Glenn Jackman wrote:
<> > At 2006-03-08 04:48AM, Dave Weaver <zen13097@zen.co.uk> wrote:
<> > 
<> > However, 
<> >     $i = -1
<> >     while (++$i < 10) {...
<> > does.
<> > 
<>  
<>  What is your favorite method for implementing a toggle switch?  Mine is:
<>  
<>  	$var = ($var + 1) % 2;


If I'm going to use the switch in boolean context only:

    $var = !$var;

else:

    $var = 1 - $var;

or:

    ($var += 1) %= 2;


Abigail
-- 
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
          q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'


------------------------------

Date: Sat, 11 Mar 2006 20:18:12 +0100
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: A Problem With GD
Message-Id: <47gm3mFf7hblU1@news.dfncis.de>

Also sprach Mark Manning:

> What is your favorite method for implementing a toggle switch?  Mine is:
>
> 	$var = ($var + 1) % 2;

The one best suited for Perl golf is of course:

    $|--;

Tassilo
-- 
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);


------------------------------

Date: Sat, 11 Mar 2006 12:13:29 -0800
From: robic0
Subject: Re: A Problem With GD
Message-Id: <bab612dvg082bedddau2h8hv75a9qthlot@4ax.com>

On Sun, 26 Feb 2006 12:57:16 +1100, "Sisyphus" <sisyphus1@nomail.afraid.org> wrote:

>
>"Mark Manning" <markem@airmail.net> wrote in message
>news:1201gn750d926e1@corp.supernews.com...
>
>> Ok - here ya go!  :-)
>>
>
>Best to post a *minimal* script that exhibits the problem. Here's all that's
>needed (though it can probably be reduced further):
>
>use GD;
>use warnings;
>use strict;
>GD::Image->trueColor(1);
>
>my ($fg, $bg, $x, $y, $i);
>
>my $b = new GD::Image( 100, 100 );
>
>#my $fg_r = 253; # Foreground -> Red
>#my $fg_g = 245; # Foreground -> Green
>#my $fg_b = 230; # Foreground -> Blue
>#my $bg_r = 205; # Background -> Red
>#my $bg_g = 192; # Background -> Green
>#my $bg_b = 176; # Background -> Blue
>
>my $fg_r = 168;
>my $fg_g = 163;
>my $fg_b = 153;
>my $bg_r = 136;
>my $bg_g = 128;
>my $bg_b = 117;
>
>$fg = $b->colorExact( $fg_r, $fg_b, $fg_b );
>$bg = $b->colorExact( $bg_r, $bg_b, $bg_b );
>
>$b->filledRectangle( 0, 0, 99, 99, $fg );
>for( $i=0; $i<500; $i++ ){
>$x = int(rand(100));
>$y = int(rand(100));
>$b->setPixel($x, $y, $bg);
>}
>
>open( OUTFILE, ">TestPic2.gif" ) || die $!;
>binmode OUTFILE;
>print OUTFILE $b->gif;
>close( OUTFILE );
>
>open( OUTFILE, ">TestPic2.png" ) || die $!;
>binmode OUTFILE;
>print OUTFILE $b->png;
>close( OUTFILE );
>
>exit( 0 );
>
>Like you, I find that if I use the values that are commented out (they're
>the values you used for for the first image files), then there's no problem.
>But if I run that script as is (using the values you used for the second
>image files), I get those extra lines of extra dots in the gif file. So ....
>the strangeness you report is dependent upon the values that are given to
>$fg_r, $fg_b, $fg_g, $bg_r, $bg_b, and $bg_g ... and probably upon something
>else as well ... but I don't know what :-)
>
>Hth.
>
>Cheers,
>Rob
>

Too bad can't macro in perl, a simple RGB(255,255,255) gets a nice
24-bit color register value.

sub RGB { return $red<<16|$green<<8|$blue }


------------------------------

Date: Sat, 11 Mar 2006 12:46:47 -0800
From: robic0
Subject: Re: A Problem With GD
Message-Id: <k7d6121lou2d21riu4g7kcbp5abtqvos1j@4ax.com>

On 11 Mar 2006 17:47:56 GMT, Abigail <abigail@abigail.nl> wrote:

>Mark Manning (markem@airmail.net) wrote on MMMMDLXXV September MCMXCIII
>in <URL:news:1215ur1bndeb911@corp.supernews.com>:
><>  Glenn Jackman wrote:
><> > At 2006-03-08 04:48AM, Dave Weaver <zen13097@zen.co.uk> wrote:
><> > 
><> > However, 
><> >     $i = -1
><> >     while (++$i < 10) {...
><> > does.
><> > 
><>  
><>  What is your favorite method for implementing a toggle switch?  Mine is:
><>  
><>  	$var = ($var + 1) % 2;
>
>
>If I'm going to use the switch in boolean context only:
>
>    $var = !$var;
>
>else:
>
>    $var = 1 - $var;
     ^^^^^^^^^^^^^^^
This is the typical proto C bool toggle also
$var = 0;
$var = 1 - $var;
 ...
>
>or:
>
>    ($var += 1) %= 2;
>
>
>Abigail

In this vane, whats a favorite way to strip a bit from map

$var &= ~($bit << $position); ?


------------------------------

Date: Sat, 11 Mar 2006 12:57:38 -0800
From: robic0
Subject: Re: A Problem With GD
Message-Id: <86e6125b47smo5g2lmb7l1dq8iso13oilq@4ax.com>

On Sat, 11 Mar 2006 12:46:47 -0800, robic0 wrote:

>On 11 Mar 2006 17:47:56 GMT, Abigail <abigail@abigail.nl> wrote:
>
>>Mark Manning (markem@airmail.net) wrote on MMMMDLXXV September MCMXCIII
>>in <URL:news:1215ur1bndeb911@corp.supernews.com>:
>><>  Glenn Jackman wrote:
>><> > At 2006-03-08 04:48AM, Dave Weaver <zen13097@zen.co.uk> wrote:
>><> > 
>><> > However, 
>><> >     $i = -1
>><> >     while (++$i < 10) {...
>><> > does.
>><> > 
>><>  
>><>  What is your favorite method for implementing a toggle switch?  Mine is:
>><>  
>><>  	$var = ($var + 1) % 2;
>>
>>
>>If I'm going to use the switch in boolean context only:
>>
>>    $var = !$var;
>>
>>else:
>>
>>    $var = 1 - $var;
>     ^^^^^^^^^^^^^^^
>This is the typical proto C bool toggle also
>$var = 0;
>$var = 1 - $var;
>...
>>
>>or:
>>
>>    ($var += 1) %= 2;
>>
>>
>>Abigail
>
>In this vane, whats a favorite way to strip a bit from map
>
>$var &= ~($bit << $position); ?
Yeah well, before this gets jumped (hijaakd) for the wrong reason

single bit:
$var &= ~(1 << $position); ?

or for a bit range starting from $position:
$number = 230010;
$var &= ~($number << $position);





------------------------------

Date: Sat, 11 Mar 2006 13:00:06 -0800
From: robic0
Subject: Re: A Problem With GD
Message-Id: <6ge61215230ph5jn6ck8p6fjgabdmlqv1f@4ax.com>

On Sat, 11 Mar 2006 12:57:38 -0800, robic0 wrote:

>On Sat, 11 Mar 2006 12:46:47 -0800, robic0 wrote:
>
>>On 11 Mar 2006 17:47:56 GMT, Abigail <abigail@abigail.nl> wrote:
>>
>>>Mark Manning (markem@airmail.net) wrote on MMMMDLXXV September MCMXCIII
>>>in <URL:news:1215ur1bndeb911@corp.supernews.com>:
>>><>  Glenn Jackman wrote:
>>><> > At 2006-03-08 04:48AM, Dave Weaver <zen13097@zen.co.uk> wrote:
>>><> > 
>>><> > However, 
>>><> >     $i = -1
>>><> >     while (++$i < 10) {...
>>><> > does.
>>><> > 
>>><>  
>>><>  What is your favorite method for implementing a toggle switch?  Mine is:
>>><>  
>>><>  	$var = ($var + 1) % 2;
>>>
>>>
>>>If I'm going to use the switch in boolean context only:
>>>
>>>    $var = !$var;
>>>
>>>else:
>>>
>>>    $var = 1 - $var;
>>     ^^^^^^^^^^^^^^^
>>This is the typical proto C bool toggle also
>>$var = 0;
>>$var = 1 - $var;
>>...
>>>
>>>or:
>>>
>>>    ($var += 1) %= 2;
>>>
>>>
>>>Abigail
>>
>>In this vane, whats a favorite way to strip a bit from map
>>
>>$var &= ~($bit << $position); ?
>Yeah well, before this gets jumped (hijaakd) for the wrong reason
>
>single bit:
>$var &= ~(1 << $position); ?
>
>or for a bit range starting from $position:
sheesh, bit range or some value (selected bits) starting from position
>$number = 230010;
>$var &= ~($number << $position);
>
>



------------------------------

Date: 11 Mar 2006 21:20:50 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: A Problem With GD
Message-Id: <slrne16fpi.2g4.abigail@alexandra.abigail.nl>

Abigail (abigail@abigail.nl) wrote on MMMMDLXXV September MCMXCIII in
<URL:news:slrne163ac.p75.abigail@alexandra.abigail.nl>:
:)  Mark Manning (markem@airmail.net) wrote on MMMMDLXXV September MCMXCIII
:)  in <URL:news:1215ur1bndeb911@corp.supernews.com>:
:) <>  Glenn Jackman wrote:
:) <> > At 2006-03-08 04:48AM, Dave Weaver <zen13097@zen.co.uk> wrote:
:) <> > 
:) <> > However, 
:) <> >     $i = -1
:) <> >     while (++$i < 10) {...
:) <> > does.
:) <> > 
:) <>  
:) <>  What is your favorite method for implementing a toggle switch?  Mine is:
:) <>  
:) <>  	$var = ($var + 1) % 2;
:)  
:)  
:)  If I'm going to use the switch in boolean context only:
:)  
:)      $var = !$var;
:)  
:)  else:
:)  
:)      $var = 1 - $var;
:)  
:)  or:
:)  
:)      ($var += 1) %= 2;


$var = [1, 0] -> [$var];


Abigail
-- 
$_ = "\x3C\x3C\x45\x4F\x54"; s/<<EOT/<<EOT/e; print;
Just another Perl Hacker
EOT


------------------------------

Date: Sat, 11 Mar 2006 16:48:04 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Toggle flags (WAS: A Problem With GD)
Message-Id: <8bDQf.9895$CI6.4350@trnddc07>

Mark Manning wrote:
> What is your favorite method for implementing a toggle switch?  Mine
> is:
> $var = ($var + 1) % 2;

Why not a simple

    $var = ! $var;

Then it's obvious that you are not doing numerics but a simple logical 
toggle.

jue






------------------------------

Date: Sat, 11 Mar 2006 14:26:57 -0600
From: Mark Manning <markem@airmail.net>
Subject: Re: Toggle flags (WAS: A Problem With GD)
Message-Id: <1216ci93kqr6o6f@corp.supernews.com>



Jürgen Exner wrote:
> Mark Manning wrote:
> 
>>What is your favorite method for implementing a toggle switch?  Mine
>>is:
>>$var = ($var + 1) % 2;
> 
> 
> Why not a simple
> 
>     $var = ! $var;
> 
> Then it's obvious that you are not doing numerics but a simple logical 
> toggle.
> 
> jue

Yes, we had to be assured of it being zero or one only.  We came across a three 
way switch at one point and simply changing the line to:

$var = ($var + 1) % 3;

Allowed us to be able to handle the toggle switch on the simulator.  :-)



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 9043
***************************************


home help back first fref pref prev next nref lref last post