<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Marilyn Burgess &#187; Perl/mod_perl</title>
	<atom:link href="http://marilynburgess.com/category/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://marilynburgess.com</link>
	<description></description>
	<lastBuildDate>Mon, 29 Aug 2011 16:33:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Send email from Perl routed through Google Apps SMTP</title>
		<link>http://marilynburgess.com/2009/07/send-email-from-perl-routed-through-google-apps-smtp/</link>
		<comments>http://marilynburgess.com/2009/07/send-email-from-perl-routed-through-google-apps-smtp/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 21:43:07 +0000</pubDate>
		<dc:creator>marilyn</dc:creator>
				<category><![CDATA[Perl/mod_perl]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[Google Apps]]></category>
		<category><![CDATA[SMTP]]></category>

		<guid isPermaLink="false">http://blog.listcentral.me/?p=364</guid>
		<description><![CDATA[I use Google Apps to manage the few email addresses I have for the listcentral.me domain. Google Apps is amazing! Very easy to use, and super powerful. For today&#8217;s small business, there is no better service for managing email, doc shares, and online calendars, specially considering the price! Unfortunately, I have encountered a problem with [...]]]></description>
			<content:encoded><![CDATA[<p>I use Google Apps to manage the few email addresses I have for the listcentral.me domain. Google Apps is amazing! Very easy to use, and super powerful. For today&#8217;s small business, there is no better service for managing email, doc shares, and online calendars, specially considering the price!</p>
<p>Unfortunately, I have encountered a problem with using Google Apps. Fortunately there is also a solution to my problem!</p>
<p><strong>The Problem</strong></p>
<p>I have a few, on demand, features on List Central that sends emails to the users, for instance, there is an &#8220;Email this list&#8221; feature. This requires that I send emails with the from address as lists@listcentral.me from my webserver to the varied email addresses of my future users. Because Google knows all about my domain listcentral.me, if any email I send from my webserver arrives at a google managed email address, google knows that the email didn&#8217;t come from it&#8217;s system, and it assumes that it must be dealing with a spammer, or other such scam.  This is not good for business, as I cannot have the emails sent from the List Central system being marked as spam!</p>
<p><strong>The Solution</strong></p>
<p>It is possible to route the emails sent from the List Central system through the Google Apps SMTP (Simple Mail Transfer Protocol) system, which has the same effect as actually sending the email through the Google Mail interface. A copy is even saved in the Sent folder!</p>
<p>Using the instructions detailed by <a href="http://robertmaldon.blogspot.com/2006/10/sending-email-through-google-smtp-from.html">Robert Maldon</a>, I was able to get my emails sending through Google&#8217;s SMTP server, and passing though the spam checks without too much hassle!</p>
<p>There was one sticking point! For those on Debian, one of the perl packages that you much install, <a href="http://search.cpan.org/search?query=Net-SMTP-SSL">Net::SMTP::SSL</a>, is available in a Debian package only for lenny. I opted to upgrade from etch for this!</p>
<p><b>The Implementation</b></p>
<p>I added a little bit to Maldon&#8217;s solution to include the multipart/alternative option in order to send both plain text and html versions of the email and allow the email viewer to choose which to display. The code is as follows:</p>
<pre class="brush: perl">
   my $fromEmail = &#039;lists@listcentral.me&#039;;
   my $emailPassword = &#039;emailpassword&#039;;
   my $toEmail = &#039;someone@somewhere.com&#039;;

   my $text = &#039;Some email message without fancy formatting!&#039;;
   my $html = &#039;&lt;b&gt;Some email message with fancy html formatting!!&lt;/b&gt;&#039;;

   my $smtp;
   if (not $smtp = Net::SMTP::SSL-&gt;new(&#039;smtp.gmail.com&#039;,
                                        Port =&gt; 465,
                                        Debug =&gt; 1)) {
      die &quot;Could not connect to mail servern&quot;;
   }

   $smtp-&gt;auth($fromEmail, $emailPassword) || die &quot;Authentication failed!n&quot;;

   $smtp-&gt;mail($fromEmail . &quot;n&quot;);
   my @recepients = split(/,/, $toEmail);
   foreach my $recp (@recepients) {
       $smtp-&gt;to($recp . &quot;n&quot;);
   }

   $smtp-&gt;data();
   $smtp-&gt;datasend(&quot;From: &quot; . $fromEmail . &quot;n&quot;);
   $smtp-&gt;datasend(&quot;To: &quot; . $toEmail . &quot;n&quot;);
   $smtp-&gt;datasend(&quot;Subject: &quot; . $subject . &quot;n&quot;);
   $smtp-&gt;datasend(&quot;MIME-Version: 1.0n&quot;);
   $smtp-&gt;datasend(&quot;Content-Type: multipart/alternative; boundary=&quot;$boundary&quot;n&quot;);
   $smtp-&gt;datasend(&quot;n--$boundaryn&quot;);
   $smtp-&gt;datasend(&quot;Content-Type: text/plain; charset=iso-8859-1n&quot;);
   $smtp-&gt;datasend(&quot;Content-Transfer-Encoding: quoted-printablen&quot;);
   $smtp-&gt;datasend($text . &quot;nn&quot;);
   $smtp-&gt;datasend(&quot;n--$boundaryn&quot;);
   $smtp-&gt;datasend(&quot;Content-Type: text/html; charset=iso-8859-1n&quot;);
   $smtp-&gt;datasend(&quot;Content-Transfer-Encoding: quoted-printablen&quot;);
   $smtp-&gt;datasend($html . &quot;n&quot;);
   $smtp-&gt;dataend();
   $smtp-&gt;quit;
</pre>
<p>In my figuring this out, I nearly fell into a couple of traps. Here&#8217;s the lessons learned: </p>
<ul>
<li>Google Email only allows SSL Authentication. There is no way around it.
<li>This means a Debian upgrade to <a href="http://www.debian.org/releases/stable/">Lenny</a> if you want to use the pre-built Debian package <a href="http://packages.debian.org/lenny/libnet-smtp-ssl-perl">libnet-smtp-ssl-perl</a>
<li>You do not have to upgrade to Google Apps Enterprise to make this happen. There is some Google documentation about Email Routing that can lead you to think you might need to upgrade for this feature, but this is a completely different feature!</li>
</ul>
<h3  class="related_post_title">You might also like...</h3><ul class="related_post"><li><a href="http://marilynburgess.com/2009/06/a-brief-history-of-perl/" title="A Brief History of Perl">A Brief History of Perl</a></li><li><a href="http://marilynburgess.com/2009/05/companies-that-use-perl/" title="Companies that Use Perl">Companies that Use Perl</a></li><li><a href="http://marilynburgess.com/2009/05/how-perl-became-my-1/" title="How Perl Became My #1">How Perl Became My #1</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://marilynburgess.com/2009/07/send-email-from-perl-routed-through-google-apps-smtp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Brief History of Perl</title>
		<link>http://marilynburgess.com/2009/06/a-brief-history-of-perl/</link>
		<comments>http://marilynburgess.com/2009/06/a-brief-history-of-perl/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 23:08:56 +0000</pubDate>
		<dc:creator>marilyn</dc:creator>
				<category><![CDATA[Perl/mod_perl]]></category>
		<category><![CDATA[Larry Wall]]></category>

		<guid isPermaLink="false">http://blog.listcentral.me/?p=292</guid>
		<description><![CDATA[Perl is older than dirt. Well, actually, that&#8217;s not true at all. Perl is older than Linux though. Perl 1.0 was released in 1987, 4 years prior to the release of the first Linux distribution. The creator of Perl, Larry Wall, got a graduate degree in Linguistics from UC Berkeley, and had grand plans to find [...]]]></description>
			<content:encoded><![CDATA[<p>Perl is older than dirt. Well, actually, that&#8217;s not true at all. Perl is older than Linux though. Perl 1.0 was released in 1987, 4 years prior to the release of the first Linux distribution. The creator of Perl, <a href="http://www.wall.org/~larry/">Larry Wall</a>, got a graduate degree in Linguistics from UC Berkeley, and had grand plans to find an unwritten language with his wife Gloria, and invent a writing scheme for it. These plans fell through, to the great advantage of computer science field!</p>
<p>Back in the day, Larry Wall programmed on Unix with the usual suspects, C, sed, awk, shell. He grew frustrated with the options available to him. So he set out to write his own language that took the best from what is avaialble, and left the rest behind. The creation of the first Perl interpreter took the better part of 1987. Wall released the first version on December 17th 1987. Through out the late 80&#8242;s and early 90&#8242;s Wall released improved versions of Perl untile 1994, when he released Perl 5, that included a complete overhaul on the Perl interpreter. Perl 5 is the version that most current Perl programemrs are accustomed to. It has had several sub-versions released through out the 90&#8242;s and the current decade. The current version is 5.10.0.</p>
<p>The Perl community has been eagerly waiting for the next major release of Perl for what feels like forever, but it&#8217;s actually only been 9 years. Work on Perl 6 began in 2000. We are still waiting on a proper release of Perl 6. Larry Wall and his team aren&#8217;t rushing it. They want to build a worthy successor to Perl 5, and they are taking their time in order to make sure they are doing it right.  Perl 6 has many differences from Perl 5, here is a select few:</p>
<ul>
<li><strong>Optional data typing system</strong> &#8211; You won&#8217;t have specify your types, just as with Perl 5, but in Perl 6, you will have the option to specify your data types</li>
<li><strong>Formal subroutine parameter list</strong> &#8211; The days of &#8216;shift&#8217; and @_ will end in Perl 6, as C/Java style subroutines will be the way in Perl 6</li>
<li><strong>Consistency with arrays and hashes</strong> &#8211; Where in Perl 5 we declare an array as @myarray, and reference an element in an array as $myarray[0], Perl 6 will maintain the @ symbol for both the declaration and the reference. To access and array element in Perl 6 will be done by: @myarray[0]. The same goes for hashes. $myhash{&#8216;item1&#8242;} will become %myhash{&#8216;item1&#8242;}</li>
<li><strong>Formal object-oriented programming</strong> &#8211; For those of you stickler who say Perl 5 isn&#8217;t object-oriented enough, Perl 6 introduces more formalized object orientation with the use of the world &#8216;Class&#8217; and everything!</li>
</ul>
<p>Perl 6 will not be back compatible with Perl 5, though there is supposed to be some sort of compatibility mode included.</p>
<p>Perl stands for <strong>P</strong>ractical <strong>E</strong>xtraction and <strong>R</strong>eport <strong>L</strong>anguage, though this  acronym was created as an after thought. Larry Wall wanted a short word for the name of the programming language, one that had positive connotations. He settled on Pearl, but laster found out that there was a real-time focused programming language called <a href="http://en.wikipedia.org/wiki/PEARL_(programming_language)">PEARL</a>, so he changed the spelling, and it has been called Perl ever since.</p>
<h3  class="related_post_title">You might also like...</h3><ul class="related_post"><li><a href="http://marilynburgess.com/2009/07/send-email-from-perl-routed-through-google-apps-smtp/" title="Send email from Perl routed through Google Apps SMTP ">Send email from Perl routed through Google Apps SMTP </a></li><li><a href="http://marilynburgess.com/2009/05/companies-that-use-perl/" title="Companies that Use Perl">Companies that Use Perl</a></li><li><a href="http://marilynburgess.com/2009/05/how-perl-became-my-1/" title="How Perl Became My #1">How Perl Became My #1</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://marilynburgess.com/2009/06/a-brief-history-of-perl/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Companies that Use Perl</title>
		<link>http://marilynburgess.com/2009/05/companies-that-use-perl/</link>
		<comments>http://marilynburgess.com/2009/05/companies-that-use-perl/#comments</comments>
		<pubDate>Fri, 22 May 2009 22:50:22 +0000</pubDate>
		<dc:creator>marilyn</dc:creator>
				<category><![CDATA[Perl/mod_perl]]></category>

		<guid isPermaLink="false">http://blog.listcentral.me/?p=290</guid>
		<description><![CDATA[The Planet Perl Iron Man Blogging Competition has come about because many people in the Perl community are getting concerned about the state of Perl. It is feared that the popularity of Perl is waning, and that it will become increasingly difficult to find gainful employment as a Perl programmer. I certainly hope that this [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-299" title="perl" src="http://marilynburgess.com/images/2009/05/perl.jpg" alt="perl" width="490" height="490" /></p>
<p>The <a href="http://ironman.enlightenedperl.org/index.html">Planet Perl Iron Man Blogging Competition</a><a></a> has come about because many people in the Perl community are getting concerned about the state of Perl. It is feared that the popularity of Perl is waning, and that it will become increasingly difficult to find gainful employment as a Perl programmer. I certainly hope that this isn&#8217;t going to be the case. Perl is an excellent language that can get the job done! Not to mention that my marketability will be severely hampered is Perl were to become obsolete. The general sentiment within the Perl community is that it is our responsibility to promote Perl, and increase its longevity together. I&#8217;m all for this, and am happy to do my part by blogging <img src='http://marilynburgess.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>As it stands right now, Perl is far from dead! There is a very active Perl community out there, and there always has been. I expect though, that it&#8217;s always been a community that isn&#8217;t to keen on touting their own horns. Let alone get in to promotion or marketing&#8230; yikes!</p>
<p>To prove that Perl is long from dead, I thought I&#8217;d list some of the big companies out there that are using Perl* in some capacity or another:</p>
<ul>
<li><a href="http://www.amazon.com/">Amazon</a> (incl. <a href="http://www.imdb.com/">IMDB</a>)</li>
<li><a href="http://www.craigslist.org/about/sites">Craigslist</a></li>
<li><a href="http://www.shopzilla.com/">Shopzilla</a></li>
<li><a href="http://bbc.co.uk/">BBC</a></li>
<li><a href="http://www.shutterstock.com/jobs.mhtml">Shutterstock</a></li>
<li><a href="http://www.activestate.com/">ActiveState</a>/<a href="http://www.sophos.com/">Sophos</a></li>
<li><a href="http://www.like.com/">Like.com</a></li>
<li><a href="http://magazines.com">Magazines.com</a></li>
</ul>
<p>Do you know any other companies that are using Perl? Help the community out, and add them to the <a href="http://www.perlfoundation.org/perl5/index.cgi?companies_using_perl">Perl 5 Wiki</a>!</p>
<p>* Sourced from the <a href="http://jobs.perl.org/">Perl Jobs</a> list, and the <a href="http://www.perlfoundation.org/perl5/index.cgi?companies_using_perl">Perl 5 Wiki</a>.</p>
<h3  class="related_post_title">You might also like...</h3><ul class="related_post"><li><a href="http://marilynburgess.com/2009/07/send-email-from-perl-routed-through-google-apps-smtp/" title="Send email from Perl routed through Google Apps SMTP ">Send email from Perl routed through Google Apps SMTP </a></li><li><a href="http://marilynburgess.com/2009/06/a-brief-history-of-perl/" title="A Brief History of Perl">A Brief History of Perl</a></li><li><a href="http://marilynburgess.com/2009/05/how-perl-became-my-1/" title="How Perl Became My #1">How Perl Became My #1</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://marilynburgess.com/2009/05/companies-that-use-perl/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How Perl Became My #1</title>
		<link>http://marilynburgess.com/2009/05/how-perl-became-my-1/</link>
		<comments>http://marilynburgess.com/2009/05/how-perl-became-my-1/#comments</comments>
		<pubDate>Fri, 15 May 2009 22:18:51 +0000</pubDate>
		<dc:creator>marilyn</dc:creator>
				<category><![CDATA[Perl/mod_perl]]></category>

		<guid isPermaLink="false">http://blog.listcentral.me/?p=287</guid>
		<description><![CDATA[As a part of the Planet Perl Iron Man Blogging Competition, Graeme Lawton asks the question: How did you get hooked? What better time to tell the story of my love affair with Perl, than now! To be totally truthful, I didn&#8217;t pick Perl, Perl picked me! In university, I took one class where we [...]]]></description>
			<content:encoded><![CDATA[<p>As a part of the <a href="http://ironman.enlightenedperl.org">Planet Perl Iron Man Blogging Competition</a>, <a href="http://graeme.per.ly/perl-how-did-you-get-hooked/237">Graeme Lawton</a>  asks the question: How did you get hooked? What better time to tell the story of my love affair with Perl, than now!</p>
<p>To be totally truthful, I didn&#8217;t pick Perl, Perl picked me! In university, I took one class where we learned a little Perl, but the rest of the time it was heavy Java, some C/C++, and some Lisp of all things! It wasn&#8217;t until I got out into the working word that Perl got its hold on me.</p>
<p>I struggled to get that first job out of university. My resume was rather un-standard, with far more soft skills gained from my experience than technical skills, and a Philosophy degree to throw everyone for a loop. I was so grateful to get the job that I finally got: Web Programmer at a leads generation and sales company. The main language used there was perl, under mod_perl, so I had to get crackin&#8217; and learn on the job. A year an a half later I&#8217;d left that company, but I couldn&#8217;t part with my Perl! I found another Perl programming job, and then another. I also started up this little thing called List Central using Perl under mod_perl.</p>
<p>Reasons I love Perl:</p>
<ul>
<li><strong> !,@,$,%,&amp;</strong>
<ul>
<li>Unlike the general sentiment of the ruby/python people, I love the funny symbols used in Perl. Once you get to know what they signify all quickly convey their meaning, and it&#8217;s easy to speed up the rate of development, because you know what you are dealing with.</li>
</ul>
</li>
<li><strong> Flexibility</strong>
<ul>
<li>The flexibility of Perl is huge for me! I&#8217;m not big on the Perl one-liners that Perl is famous for. I like that I don&#8217;t have to be all cutesie and smartie pants showing off how few lines I can complete a task in. I like to be verbose and include all of my braces, and with Perl I can! And those that like the one-liners, they can enjoy their way too!</li>
</ul>
</li>
<li><strong> CPAN</strong>
<ul>
<li>CPAN is super useful. One of the most comprehensive and well documented libraries available in any language. And it&#8217;s all open source. A beautiful example of the power of open source!</li>
</ul>
</li>
<li><strong> Objects or Scripts<br />
</strong></p>
<ul>
<li>Again, this is part of the whole flexibility thing. Perl is capable of quick and dirty scripts as well as massive projects designed with proper object orientation. With Perl, the developer gets to decide!</li>
</ul>
</li>
</ul>
<p>How did you get into Perl? Why do you love it?</p>
<h3  class="related_post_title">You might also like...</h3><ul class="related_post"><li><a href="http://marilynburgess.com/2009/07/send-email-from-perl-routed-through-google-apps-smtp/" title="Send email from Perl routed through Google Apps SMTP ">Send email from Perl routed through Google Apps SMTP </a></li><li><a href="http://marilynburgess.com/2009/06/a-brief-history-of-perl/" title="A Brief History of Perl">A Brief History of Perl</a></li><li><a href="http://marilynburgess.com/2009/05/companies-that-use-perl/" title="Companies that Use Perl">Companies that Use Perl</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://marilynburgess.com/2009/05/how-perl-became-my-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Changing Pixel Colors With ImageMagick</title>
		<link>http://marilynburgess.com/2009/05/changing-pixel-colors-with-imagemagick/</link>
		<comments>http://marilynburgess.com/2009/05/changing-pixel-colors-with-imagemagick/#comments</comments>
		<pubDate>Fri, 08 May 2009 21:48:49 +0000</pubDate>
		<dc:creator>marilyn</dc:creator>
				<category><![CDATA[Perl/mod_perl]]></category>
		<category><![CDATA[ImageMagick]]></category>
		<category><![CDATA[PerlMagick]]></category>

		<guid isPermaLink="false">http://blog.listcentral.me/?p=109</guid>
		<description><![CDATA[On List Central, users will be able to choose from a selection of themes for their main page. The themes available only vary by color. To make this happen I have several sets of CSS files; when the user logs in, the system checks which theme s/he selected, and serves the appropriate CSS files. These [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_267" class="wp-caption alignleft" style="width: 124px"><img class="size-full wp-image-267" title="logo" src="http://marilynburgess.com/images/2009/04/logo.jpg" alt="ImageMagick" width="114" height="118" /><p class="wp-caption-text">ImageMagick</p></div>
<p>On List Central, users will be able to choose from a selection of themes for their main page. The themes available only vary by color. To make this happen I have several sets of CSS files; when the user logs in, the system checks which theme s/he selected, and serves the appropriate CSS files. These sets of CSS files are automatically created from a base set of CSS files when a them is created in the List Central Administration.</p>
<p>Aside from the CSS files, there are several images on the users&#8217; main page that vary depending on what theme is selected. In the name of saving time in the future, I set out to figure out a way to create these images automatically as well. I really don&#8217;t like busy work, and I&#8217;m willing to go to great lengths to find a way around having to do any!</p>
<p>My general approach was, for each image, go through each and every pixel in the image, and see if it is one of the colors I want to change. If it is, then I change it, else, I don&#8217;t do anything with it. I&#8217;m assuming that the image will only have the colors I want to change in it. The code can easily be modified to handle this case differently. </p>
<p>On with the code!</p>
<div class="code">
my @BaseColors = (&#8216;#ffffff&#8217;, &#8216;#0000ff&#8217;, &#8216;#00ff00&#8242;, &#8216;#ff0000&#8242;, &#8216;#000000&#8242;);<br />
my @NewColors = (&#8216;#ffffff&#8217;, &#8216;#121d52&#8242;, &#8216;#1d687a&#8217;, &#8216;#bdeaff&#8217;, &#8216;#f8f8ff&#8217;);</p>
<p>my $imSrcImg = new Image::Magick;<br />
my $imagefile = &#8216;source_image.png&#8217;;<br />
my $warn = $imSrcImg->Read($imagefile);<br />
print &#8216;READ WARN: $warn&#8217;;</p>
<p>my ($width, $height) = $imSrcImg->Get(&#8216;width&#8217;, &#8216;height&#8217;);<br />
print &#8216;GET WARN: $warn&#8217;;</p>
<p>my $size = $width . &#8216;x&#8217; . $height;<br />
my $iMagickNew = new Image::Magick(size=>$size);<br />
$warn = $iMagickNew->ReadImage(&#8216;NULL:white&#8217;);<br />
print &#8216;ReadImage WARN: $warn&#8217;);</p>
<p># Iterate over every pixel in the image and change<br />
for my $y (0..($height-1)){<br />
&nbsp;&nbsp;&nbsp;for my $x (0..($width-1)){</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my (@pixel) = split(/,/, $imSrcImg->Get(&#8216;pixel[$x,$y]&#8216;));</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $red = DecToHex($pixel[0]);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $green = DecToHex($pixel[1]);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $blue = DecToHex($pixel[2]);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $color = &#8216;#&#8217; . $red . $green . $blue;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Check all of the colors we are going to be changing<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(my $i = 0; $i <  @BaseColors; $i++ ) {</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Change pixel color if the pixel is the color of one<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#   of our base colors but not if it's the color we<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#   want to change it to already to save a fraction<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#   of a moment<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if($color eq  $BaseColors[$i] &#038;&#038; $color ne $NewColors[$i]){</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Pull out the red, green, &#038; blue components<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $r; my $g; my $b;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $changeToColor = $NewColors[$i];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if($changeToColor =~ m/#([wd]{2})([wd]{2})([wd]{2})/){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$r = $1; $g = $2; $b = $3;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# Convert to hex<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $red = HexToDec($r);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $green = HexToDec($g);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $blue = HexToDec($b);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $toColorHex = '#'.$r.$g.$b;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $toColorDec = '$red, $green, $blue';</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $x2 = $x + 1; my $y2 = $y + 1;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $warn = $iMagickNew->Draw(fill=>$toColorHex, primitive=>&#8217;point&#8217;, points=>&#8217;$x,$y&#8217;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print &#8216;Changing pixl [$x,$y] from $color to $toColorHex ($toColorDec)nWARN: $warn&#8217;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}</p>
<p># Write the new image, then we are done<br />
my $newImage = &#8216;new_image.png&#8217;;<br />
my $warn = $iMagickNew->Write($newImage);<br />
print &#8216;WARN: $warn&#8217;;</p>
<p># Converts a decimal number to a hexidecimal number<br />
sub DecToHex {<br />
&nbsp;&nbsp;&nbsp;my $dec = shift;</p>
<p>&nbsp;&nbsp;&nbsp;my $hex = sprintf(&#8216;%X&#8217;, $dec);<br />
&nbsp;&nbsp;&nbsp;if($hex =~ m/^([wd]{2})/){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$hex = $1;<br />
&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;&nbsp;$hex = lc($hex);<br />
&nbsp;&nbsp;&nbsp;return $hex;<br />
} </p>
<p># Converts a hexidecimal number to a decimal number<br />
sub HexToDec {<br />
&nbsp;&nbsp;&nbsp;my $hex = shift;</p>
<p>&nbsp;&nbsp;&nbsp;my $dec = hex($hex);</p>
<p>&nbsp;&nbsp;&nbsp;return $dec;<br />
}
</p></div>
<p><strong>WARNING</strong>: This code will not work as is. There are apostrophes that should be double apostrophes and other such aesthetic changes. </p>
<p>I&#8217;ve played around with ImageMagick in the past, so it was the logical choice for my image manipulation package.</p>
<p>I had one major sticking point in trying to get my pixels to change color, which all stemmed from the lack of quality documentation available for the ImageMagick perl package. I love PerlMagick! It is super powerful! It has always baffled me how poor the documentation is. Hopefully my sharing this tidbit will help some other poor soul out there who is struggling with Perl Magick. </p>
<p>Here&#8217;s the crux of it: You cannot get a pixel to display in a certain color with:</p>
<div class="code">
$iMagick->Set(&#8216;pixel[49,49]&#8216;=>&#8217;red&#8217;);
</div>
<p>as you might assume from the documentation. You have to use the &#8216;Draw&#8217; subroutine like this:</p>
<div class="code">
$iMagick->Draw(fill=>red, primitive=>&#8217;point&#8217;, points=>&#8217;49,49);
</div>
<p>It took me hours to figure that out! </p>
<p>I hope my future users like the whole theme selection business on List Central after all of this effort! It was fun to make it happen though! Its a win win!</p>
<h3  class="related_post_title">You might also like...</h3><ul class="related_post"><li><a href="http://marilynburgess.com/2009/07/send-email-from-perl-routed-through-google-apps-smtp/" title="Send email from Perl routed through Google Apps SMTP ">Send email from Perl routed through Google Apps SMTP </a></li><li><a href="http://marilynburgess.com/2009/06/a-brief-history-of-perl/" title="A Brief History of Perl">A Brief History of Perl</a></li><li><a href="http://marilynburgess.com/2009/05/companies-that-use-perl/" title="Companies that Use Perl">Companies that Use Perl</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://marilynburgess.com/2009/05/changing-pixel-colors-with-imagemagick/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Will CPAN and Debian ever play nice?</title>
		<link>http://marilynburgess.com/2009/03/will-cpan-and-debian-ever-play-nice/</link>
		<comments>http://marilynburgess.com/2009/03/will-cpan-and-debian-ever-play-nice/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 22:59:59 +0000</pubDate>
		<dc:creator>marilyn</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Perl/mod_perl]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CPAN]]></category>

		<guid isPermaLink="false">http://blog.listcentral.me/?p=15</guid>
		<description><![CDATA[Sometimes I feel like the only adult at the playground, desperately trying, in vein, to get the kids to play nice, but they refuse to do so! I love CPAN! There is no other library like it. So well organized, incredibly comprehensive, and an amazingly large contributor base. It is beautiful for the code and [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes I feel like the only adult at the playground, desperately trying, in vein, to get the kids to play nice, but they refuse to do so!</p>
<p>I love <a href="http://search.cpan.org/">CPAN</a>! There is no other library like it. So well organized, incredibly comprehensive, and an amazingly large <a href="http://hexten.net/cpan-faces/">contributor base</a>. It is beautiful for the code and for the community.</p>
<p>I love <a href="http://www.debian.org/">Debian</a>! The best of all Linux distributions, Debian offers usability to the Linux community, even to the server maintainers, and for the most part, applications just plain work when installed via the <a href="http://www.debian.org/doc/manuals/apt-howto/">apt package manager</a>.</p>
<p>In the last year or two its become clear the CPAN and Debian should be put on naughty spots or some other such punishment as their interaction has made me, a long time user of both, very frustrated. I recently started renting a dedicated server from <a href="http://www.serverpronto.com/">ServerPronto</a> in preparation for the upcoming release of List Central. This required that I build a new Debian machine to have all of the applications and modules that I like to use. Everything was going beautifully until I reached the task of installing my 3rd party Perl modules. I&#8217;ve been a Perl programmer for quite a few years now, so my instinct was to go to CPAN and install via the command line. Over and over again the installation of my modules, ones that work perfectly on my home server, failed, with very lengthy and arcane error messages. Through much googling and trail and error I found the answer in pre-built Debian packages that are to be installed via the apt package manager that provide my much loved Perl modules. It took 2 frustrating days to figure out which CPAN modules had a corresponding Debian package to install, and which needed CPAN.</p>
<p>The effort to bring CPAN and Debian into sync is evident in this migration of Perl modules to Debian packages, but it misses the mark. As with many open source projects it seems that the developers have once again forgotten about the user. Why does CPAN burp up a bunch of garbage when I try to install modules that have Debian packages to install instead? Would it really be too hard to have CPAN figure out that I&#8217;m on Debian, and tell me that there is a package that I should be installing instead?</p>
<p>Linux is growing in popularity, and Debian (with <a href="http://www.ubuntu.com/">Ubuntu</a>) is at the forefront.  Communication with the user has to be made a priority, or else frustrations like this one are likely to cause people to go back to the alternatives they are used to.</p>
<h3  class="related_post_title">You might also like...</h3><ul class="related_post"><li><a href="http://marilynburgess.com/2009/07/send-email-from-perl-routed-through-google-apps-smtp/" title="Send email from Perl routed through Google Apps SMTP ">Send email from Perl routed through Google Apps SMTP </a></li><li><a href="http://marilynburgess.com/2009/06/a-brief-history-of-perl/" title="A Brief History of Perl">A Brief History of Perl</a></li><li><a href="http://marilynburgess.com/2009/05/companies-that-use-perl/" title="Companies that Use Perl">Companies that Use Perl</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://marilynburgess.com/2009/03/will-cpan-and-debian-ever-play-nice/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>LAMP at List Central</title>
		<link>http://marilynburgess.com/2009/03/lamp-at-list-central/</link>
		<comments>http://marilynburgess.com/2009/03/lamp-at-list-central/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 22:58:12 +0000</pubDate>
		<dc:creator>marilyn</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Perl/mod_perl]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[mod_perl]]></category>

		<guid isPermaLink="false">http://blog.listcentral.me/?p=18</guid>
		<description><![CDATA[For all of those interested, I thought I&#8217;d describe the setup of my server that is home to what will be List Central. List Central runs on a LAMP (Linux, Apache, mySQL, and Perl) server. As List Central is still under development, I&#8217;ve done my best to use all of the most current stable versions [...]]]></description>
			<content:encoded><![CDATA[<p>For all of those interested, I thought I&#8217;d describe the setup of my server that is home to what will be List Central.</p>
<p>List Central runs on a LAMP (Linux, Apache, mySQL, and Perl) server. As List Central is still under development, I&#8217;ve done my best to use all of the most current stable versions of everything. The details are below:</p>
<ul>
<li>Debian Etch</li>
<li>Apache2 (mpm-prefork) Version 2.2</li>
<li>mySQL 5.0</li>
<li>Perl 5.8.8</li>
<li>Mod_perl: libapache2-mod-perl2 Version2.0.2-2.4</li>
<li>Apache Request Library: libapache2-mod-apreq2 Version 2.08-4</li>
<li>PHP 5 installed for WordPress</li>
</ul>
<p>I am quite happy with my current setup, though I&#8217;ll admit that it took me years to get comfortable being a Linux server administrator. Feel free to ask system related questions here.  Discussions between those whom have similar setups are very welcome!</p>
<h3  class="related_post_title">Random Posts</h3><ul class="related_post"><li><a href="http://marilynburgess.com/2010/03/why-you-should-follow/" title="Why you should follow @DrWayneWDyer #FollowFriday">Why you should follow @DrWayneWDyer #FollowFriday</a></li><li><a href="http://marilynburgess.com/2010/09/betty-the-spider-and-my-conundrum/" title="Betty the spider, and my conundrum">Betty the spider, and my conundrum</a></li><li><a href="http://marilynburgess.com/2011/03/5-writers-that-make-you-think/" title="5 Writers That Make You Think">5 Writers That Make You Think</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://marilynburgess.com/2009/03/lamp-at-list-central/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

