<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>vamp: dm: Perl &amp;lt;&amp;#8212;&amp;gt; PHP</title>
    <link>http://www.dminor.com/blog/articles/2004/02/07/perl-lt-8212-gt-php</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>variations on a short vamp in d minor</description>
    <item>
      <title>Perl &amp;amp;lt;&amp;amp;#8212;&amp;amp;gt; PHP</title>
      <description>&lt;p&gt;A while back, one of the guys I chat with occasionally sent me a link &lt;a href="http://www.cs.wcupa.edu/~rkline/perl2php/"&gt;showing how to translate a task in both Perl and &lt;span class="caps"&gt;PHP&lt;/span&gt;&lt;/a&gt; side by side by &lt;a href="rkline@wcupa.edu"&gt;Robert Kline&lt;/a&gt;.  I printed it off and read it last night while at McDonald&amp;#8217;s letting the boys burn off some winter energy.  I&amp;#8217;ve had some interest for a while about learning &lt;a href="http://www.perl.org"&gt;Perl&lt;/a&gt; for a number of reasons that I won&amp;#8217;t go into.&lt;/p&gt;


	&lt;p&gt;All in all, Perl does things more succinctly as I see it.  There are examples of where &lt;a href="http://www.php.net"&gt;&lt;span class="caps"&gt;PHP&lt;/span&gt;&lt;/a&gt; ties things up better (faster), but for the most part, it takes several more characters to do a task than in Perl.  Typically, that&amp;#8217;s because the functions are more descriptive in &lt;span class="caps"&gt;PHP&lt;/span&gt;.  For instance:&lt;/p&gt;


	&lt;p&gt;In Perl:   &lt;code&gt;$s =~ s/^\s+|\s+$//g;&lt;/code&gt;  &lt;br /&gt;
In &lt;span class="caps"&gt;PHP&lt;/span&gt;:    &lt;code&gt;$s = rtrim($s);&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;But what excites me the most about Perl is the &lt;a href="http://www.cs.wcupa.edu/~rkline/perl2php/#htmlelements"&gt;section on &lt;span class="caps"&gt;HTML&lt;/span&gt; Elements&lt;/a&gt;.  Dropping variables into &lt;span class="caps"&gt;HTML&lt;/span&gt; is one of the things that excited me about &lt;span class="caps"&gt;PHP&lt;/span&gt; when I was looking for a scripting language to add to my skills coming from just a designer standpoint.  Being able to switch between &lt;span class="caps"&gt;HTML&lt;/span&gt;/PHP modes in a script was nice to keep the two modes separate in my head.  What has frustrated as I&amp;#8217;ve switched to almost exclusively scripting instead of designing is that switching between modes to output &lt;span class="caps"&gt;PHP&lt;/span&gt; variables took a lot of keystrokes!  and it seemed that writing the &lt;span class="caps"&gt;HTML&lt;/span&gt; for something like a form could be written by hinting to &lt;span class="caps"&gt;PHP&lt;/span&gt; what I wanted to do.  I&amp;#8217;m sure there is a &lt;a href="http://pear.php.com"&gt;&lt;span class="caps"&gt;PEAR&lt;/span&gt;&lt;/a&gt; package that does this, but I&amp;#8217;m not really looking to continue developing much in &lt;span class="caps"&gt;PHP&lt;/span&gt;, so I haven&amp;#8217;t looked.&lt;/p&gt;


	&lt;p&gt;What Kline&amp;#8217;s comparison points to (if I&amp;#8217;m reading it correctly) is that these lines should output the same thing:&lt;/p&gt;


	&lt;p&gt;In Perl:  &lt;code&gt;submit({value=&amp;gt;"yy"})&lt;/code&gt;&lt;br /&gt;
In &lt;span class="caps"&gt;PHP&lt;/span&gt;:   &lt;code&gt;&amp;lt;input type="submit" value="&amp;lt;?php echo $_POST['yy']; ?&amp;gt;"&amp;gt;&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;My only complaint with what I see right now (and I admit I haven&amp;#8217;t studied this much at all) is that the output of the Perl package is &lt;span class="caps"&gt;HTML 4&lt;/span&gt;.0.  I would hope that there is a package that outputs &lt;span class="caps"&gt;XHTML&lt;/span&gt; too.  I&amp;#8217;ll have to look into this more.&lt;/p&gt;


	&lt;p&gt;All in all, this makes me excited about picking up Perl as another tool for development.  I don&amp;#8217;t want to start a debate about whether Perl or &lt;span class="caps"&gt;PHP&lt;/span&gt; are better.  I just want to know both.&lt;/p&gt;</description>
      <pubDate>Sat, 07 Feb 2004 16:45:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:4375bc91bfb7dff90bc652fdf622809f</guid>
      <author>dminor</author>
      <link>http://www.dminor.com/blog/articles/2004/02/07/perl-lt-8212-gt-php</link>
      <category>Programming</category>
    </item>
  </channel>
</rss>
