<?xml version='1.0' encoding='utf-8' ?>

<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' xmlns:atom10='http://www.w3.org/2005/Atom'>
<channel>
  <title>Dreamwidth Development Training</title>
  <link>https://dw-dev-training.dreamwidth.org/</link>
  <description>Dreamwidth Development Training - Dreamwidth Studios</description>
  <lastBuildDate>Tue, 01 May 2012 22:16:31 GMT</lastBuildDate>
  <generator>LiveJournal / Dreamwidth Studios</generator>
  <lj:journal>dw_dev_training</lj:journal>
  <lj:journaltype>community</lj:journaltype>
  <image>
    <url>https://v2.dreamwidth.org/92798/30813</url>
    <title>Dreamwidth Development Training</title>
    <link>https://dw-dev-training.dreamwidth.org/</link>
    <width>100</width>
    <height>100</height>
  </image>

<item>
  <guid isPermaLink='true'>https://dw-dev-training.dreamwidth.org/34384.html</guid>
  <pubDate>Tue, 01 May 2012 22:16:31 GMT</pubDate>
  <title>DW object-oriented programming explained (Part 3) - using classes</title>
  <link>https://dw-dev-training.dreamwidth.org/34384.html</link>
  <description>Posted by: &lt;span lj:user=&apos;sophie&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://sophie.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://sophie.dreamwidth.org/&apos;&gt;&lt;b&gt;sophie&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It&apos;s been a while since I posted anything in &lt;a href=&quot;http://dw-dev-training.dreamwidth.org/tag/object-oriented+programming&quot;&gt;this series of entries&lt;/a&gt;, and I apologise for that! Today, though, I&apos;ll be explaining how to actually use classes in Perl and the Dreamwidth code and constructing new objects.&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;cut-wrapper&quot;&gt;&lt;span style=&quot;display: none;&quot; id=&quot;span-cuttag___1&quot; class=&quot;cuttag&quot;&gt;&lt;/span&gt;&lt;b class=&quot;cut-open&quot;&gt;(&amp;nbsp;&lt;/b&gt;&lt;b class=&quot;cut-text&quot;&gt;&lt;a href=&quot;https://dw-dev-training.dreamwidth.org/34384.html#cutid1&quot;&gt;How do you use classes?&lt;/a&gt;&lt;/b&gt;&lt;b class=&quot;cut-close&quot;&gt;&amp;nbsp;)&lt;/b&gt;&lt;/span&gt;&lt;div style=&quot;display: none;&quot; id=&quot;div-cuttag___1&quot; aria-live=&quot;assertive&quot;&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;That&apos;s a lot to take in, so I&apos;ll leave off for now! I hope I&apos;ve explained things well, but I&apos;m sure that there are bits that are going to be incomprehensible. If you need me to explain anything further, please ask in the comments - I&apos;ll be happy to try to explain it.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=dw_dev_training&amp;ditemid=34384&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://dw-dev-training.dreamwidth.org/34384.html</comments>
  <category>perl</category>
  <category>beginner guide</category>
  <category>object-oriented programming</category>
  <lj:security>public</lj:security>
  <lj:poster>sophie</lj:poster>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://dw-dev-training.dreamwidth.org/32468.html</guid>
  <pubDate>Fri, 17 Feb 2012 23:27:28 GMT</pubDate>
  <title>DW object-oriented programming explained (Part 2)</title>
  <link>https://dw-dev-training.dreamwidth.org/32468.html</link>
  <description>Posted by: &lt;span lj:user=&apos;sophie&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://sophie.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://sophie.dreamwidth.org/&apos;&gt;&lt;b&gt;sophie&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Welcome to the second part of the series on object-oriented programming - or OO - as it applies to the Dreamwidth codebase. :)&lt;br /&gt;&lt;br /&gt;If you haven&apos;t already read the &lt;a href=&quot;http://dw-dev-training.dreamwidth.org/31843.html&quot;&gt;first part&lt;/a&gt;, you&apos;ll want to do that before reading this part. I also realise that I never got around to explaining what &apos;methods&apos; are in the first post, so I&apos;m going to do that right now before delving into the main part of this post:&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;cut-wrapper&quot;&gt;&lt;span style=&quot;display: none;&quot; id=&quot;span-cuttag___1&quot; class=&quot;cuttag&quot;&gt;&lt;/span&gt;&lt;b class=&quot;cut-open&quot;&gt;(&amp;nbsp;&lt;/b&gt;&lt;b class=&quot;cut-text&quot;&gt;&lt;a href=&quot;https://dw-dev-training.dreamwidth.org/32468.html#cutid1&quot;&gt;What are methods?&lt;/a&gt;&lt;/b&gt;&lt;b class=&quot;cut-close&quot;&gt;&amp;nbsp;)&lt;/b&gt;&lt;/span&gt;&lt;div style=&quot;display: none;&quot; id=&quot;div-cuttag___1&quot; aria-live=&quot;assertive&quot;&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;As with the last post, if you have any questions on this, feel free to let me know in the comments!&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;So, with that explanation of methods out of the way, it&apos;s time to move onto our next topic - how it applies to the DW codebase.&lt;br /&gt;&lt;br /&gt;I&apos;m going to do this as a few posts, each dealing with their own topic, because I&apos;ve got a fair amount to say about them. I&apos;m still not entirely sure how many there&apos;ll be, but I&apos;m writing them one at a time so there may be some time (a few days to a week) between each one.&lt;br /&gt;&lt;br /&gt;A couple of things to note before I begin:&lt;ul&gt;&lt;li&gt;This post may require some basic knowledge of Perl and/or programming in general. Not much, I promise! (Things such as what a &apos;string&apos; is, etc.) But all the same, if anybody finds themselves confused by anything I write, feel free to ask for clarification in the comments. I won&apos;t bite!&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Secondly, if you&apos;re used to OO from another language, you&apos;ll find some things about Perl&apos;s implementation of OO to be strange and baffling. That&apos;s because Perl wasn&apos;t actually designed with OO in mind; OO support came later, and to be honest, it shows. Still, it&apos;s what we use, so I hope I can at least help with understanding it.&lt;sup&gt;&lt;a href=&quot;#dw-oo2-perl6&quot;&gt;(**)&lt;/a&gt;&lt;/sup&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;small&gt;&lt;sup&gt;(**)&lt;/sup&gt; There &lt;em&gt;is&lt;/em&gt; a version of Perl in the works which does a much better job of not only OO but a lot of other things - &lt;a href=&quot;http://dev.perl.org/perl6/&quot;&gt;Perl 6&lt;/a&gt; - but at the cost of revamping a lot of the language such that you probably wouldn&apos;t be able to use it without spending some time making sure your code conformed to it. For this series, therefore, I&apos;ll be concentrating on Perl 5, which is what most Perl developers - including DW and LJ - use.&lt;/small&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;With all that said, let&apos;s move onto our first topic!&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;cut-wrapper&quot;&gt;&lt;span style=&quot;display: none;&quot; id=&quot;span-cuttag___2&quot; class=&quot;cuttag&quot;&gt;&lt;/span&gt;&lt;b class=&quot;cut-open&quot;&gt;(&amp;nbsp;&lt;/b&gt;&lt;b class=&quot;cut-text&quot;&gt;&lt;a href=&quot;https://dw-dev-training.dreamwidth.org/32468.html#cutid2&quot;&gt;What is an &apos;object&apos; in Perl?&lt;/a&gt;&lt;/b&gt;&lt;b class=&quot;cut-close&quot;&gt;&amp;nbsp;)&lt;/b&gt;&lt;/span&gt;&lt;div style=&quot;display: none;&quot; id=&quot;div-cuttag___2&quot; aria-live=&quot;assertive&quot;&gt;&lt;/div&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;That&apos;s about it for this post. There&apos;s a lot of stuff here so feel free to ask questions if there&apos;s anything you don&apos;t understand! My next post will probably talk about how you can create and use an object, as well as some example of existing classes in the codebase.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=dw_dev_training&amp;ditemid=32468&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://dw-dev-training.dreamwidth.org/32468.html</comments>
  <category>perl</category>
  <category>object-oriented programming</category>
  <category>beginner guide</category>
  <lj:security>public</lj:security>
  <lj:poster>sophie</lj:poster>
  <lj:reply-count>18</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://dw-dev-training.dreamwidth.org/31370.html</guid>
  <pubDate>Fri, 03 Feb 2012 20:09:30 GMT</pubDate>
  <title>Strip tab characters from multiple text files and replace them with spaces (or something else)</title>
  <link>https://dw-dev-training.dreamwidth.org/31370.html</link>
  <description>Posted by: &lt;span lj:user=&apos;delladea&apos; style=&apos;white-space: nowrap; text-decoration: line-through;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://delladea.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://delladea.dreamwidth.org/&apos;&gt;&lt;b&gt;delladea&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I switch between Gedit, Notepad++, and vim fairly often depending on what I&apos;m doing and whose computer I&apos;m on.  Sometimes I end up with tab characters where I really wanted four spaces, mainly when I&apos;m using vim and I haven&apos;t figured out how to get vim to &lt;i&gt;not do this&lt;/i&gt;.  Gedit and Notepad++ have settings to use spaces instead of tabs, so there&apos;s no issue there.&lt;br /&gt;&lt;br /&gt;Either I don&apos;t notice the tab characters until after I&apos;ve put lots of them in the file I&apos;m editing, or I&apos;m editing a file from someone else whose editor uses tab characters for indentation.  I know its not a big deal to some people, but tab indentation mixed with space indentation is a huge pet peeve of mine.  &lt;br /&gt;&lt;br /&gt;Thus, a perl script was born:&lt;br /&gt;&lt;br /&gt;&lt;textarea cols=&quot;70&quot; rows=&quot;10&quot;&gt;#!/usr/bin/perl -w

use File::Copy;

# This script replaces tab characters in a file with four spaces, or whatever else you want

$num_args = $#ARGV + 1;
$num_warnings = 0;
$tab_replace = &quot;    &quot;;  # Change this to whatever you want in place of tabs

if ( $num_args == 0 ) {
    print &quot;usage: strip-tabs.pl file1 [file2, file3...]\n&quot;;
    exit;
}

# Have files to parse...
for my $f ( 0 .. ($num_args - 1) ) {
    if ( open(INPUTFILE, &quot;&amp;lt;$ARGV[$f]&quot;) ) {
       if ( open(OUTPUTFILE, &quot;&amp;gt;$ARGV[$f]~&quot;) ) {
           # Start parsing the file
           while ( my $line = &amp;lt;INPUTFILE&amp;gt; ) {
               $line =~ s/\t/$tab_replace/g;
               print OUTPUTFILE $line;
           }
           # Copy over original file here
           close(OUTPUTFILE);
           close(INPUTFILE);
           if ( !move(&quot;$ARGV[$f]~&quot;, $ARGV[$f]) ) {
               print &quot;Could not write output to file $ARGV[$f]: $!\n&quot;;
               $num_warnings += 1;
           }
       }
       else {
           close(INPUTFILE);
           print &quot;Could not create output file for $ARGV[$f]: $!\n&quot;;
           $num_warnings += 1;
       }
    }
    else {
        print &quot;Could not open $ARGV[$f] for reading: $!\n&quot;;
        $num_warnings += 1;
    }
}
die &quot;$num_warnings warnings encountered during file operation.&quot; unless $num_warnings == 0;&lt;/textarea&gt;&lt;br /&gt;&lt;a href=&quot;https://gist.github.com/1724758&quot;&gt;View Gist (strip-tabs.pl)&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Feel free to gank away if you find it useful!&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=dw_dev_training&amp;ditemid=31370&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://dw-dev-training.dreamwidth.org/31370.html</comments>
  <category>text editors</category>
  <category>perl</category>
  <lj:mood>relaxed</lj:mood>
  <lj:security>public</lj:security>
  <lj:poster>delladea</lj:poster>
  <lj:reply-count>13</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://dw-dev-training.dreamwidth.org/25840.html</guid>
  <pubDate>Thu, 09 Jun 2011 16:29:32 GMT</pubDate>
  <title>&quot;I wonder what this perl code does...&quot;</title>
  <link>https://dw-dev-training.dreamwidth.org/25840.html</link>
  <description>Posted by: &lt;span lj:user=&apos;pauamma&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://pauamma.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://pauamma.dreamwidth.org/&apos;&gt;&lt;b&gt;pauamma&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When I get one of those moments, I reach for &quot;perl -e&quot; (because it&apos;s always available with perl), but someone mentioned the following 2 tools recently on a mailing list I read, so I thought I&apos;d pass them on:&lt;br /&gt;&lt;br /&gt;- &lt;a href=&quot;http://search.cpan.org/~sukria/perlconsole-0.4/perlconsole&quot;&gt;perlconsole&lt;/a&gt;&lt;br /&gt;- &lt;a href=&quot;http://search.cpan.org/~doy/Devel-REPL-1.003012/lib/Devel/REPL.pm&quot;&gt;Devel::Repl&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;(&lt;a href=&quot;http://perl.dreamwidth.org/4600.html&quot;&gt;Crossposted to&lt;/a&gt; &lt;span style=&apos;white-space: nowrap;&apos;&gt;&lt;a href=&apos;https://perl.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/community.png&apos; alt=&apos;[community profile] &apos; width=&apos;16&apos; height=&apos;16&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://perl.dreamwidth.org/&apos;&gt;&lt;b&gt;perl&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;.)&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=dw_dev_training&amp;ditemid=25840&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://dw-dev-training.dreamwidth.org/25840.html</comments>
  <category>perl</category>
  <lj:security>public</lj:security>
  <lj:poster>pauamma</lj:poster>
  <lj:reply-count>4</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://dw-dev-training.dreamwidth.org/23661.html</guid>
  <pubDate>Tue, 31 Aug 2010 16:43:54 GMT</pubDate>
  <title>Nifty perl trick I learned about today</title>
  <link>https://dw-dev-training.dreamwidth.org/23661.html</link>
  <description>Posted by: &lt;span lj:user=&apos;pauamma&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://pauamma.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://pauamma.dreamwidth.org/&apos;&gt;&lt;b&gt;pauamma&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Context was someone asking why&lt;blockquote&gt;print &quot;Hello, world!\n&quot; &amp;amp;&amp;amp; die;&lt;/blockquote&gt;doesn&apos;t output anything. Someone replied with a nifty trick to help figure this out:&lt;blockquote&gt;perl -MO=Deparse -e &apos;print &quot;Hello, world!\n&quot; &amp;amp;&amp;amp; die;&apos;&lt;/blockquote&gt;(go ahead and try it in your Dreamhack).&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=dw_dev_training&amp;ditemid=23661&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://dw-dev-training.dreamwidth.org/23661.html</comments>
  <category>perl</category>
  <category>tips</category>
  <lj:security>public</lj:security>
  <lj:poster>pauamma</lj:poster>
  <lj:reply-count>6</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://dw-dev-training.dreamwidth.org/23103.html</guid>
  <pubDate>Sun, 25 Jul 2010 09:08:27 GMT</pubDate>
  <title>Writing to the database through a Perl script in Dreamwidth, placeholders</title>
  <link>https://dw-dev-training.dreamwidth.org/23103.html</link>
  <description>Posted by: &lt;span lj:user=&apos;anarres&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://anarres.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://anarres.dreamwidth.org/&apos;&gt;&lt;b&gt;anarres&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In Dreamwidth you can interact with the database using Perl&apos;s DBI module, but with a few Dreamwidth-specific methods layered on top. I&apos;ve been trying to figure out how to write new rows to a database table. After looking at some other Dreamwidth scripts to see how it&apos;s done, I wrote the following script (which doesn&apos;t work):&lt;br /&gt;&lt;br /&gt;# -------------------- ~/dw/bin/dev/test.pl ----------------------------&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;&lt;br /&gt;use lib &quot;$ENV{LJHOME}/cgi-bin&quot;;&lt;br /&gt;require &apos;ljlib.pl&apos;;&lt;br /&gt;use strict;&lt;br /&gt;use warnings;&lt;br /&gt;&lt;br /&gt;my $cart = {&lt;br /&gt;    authcode =&amp;gt; &apos;blahblahblahblah&apos;,&lt;br /&gt;    userid =&amp;gt; 12,&lt;br /&gt;    cartid =&amp;gt; 33,&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;my $dbh = LJ::get_db_writer() or return undef;&lt;br /&gt;&lt;br /&gt;$dbh-&amp;gt;do(&lt;br /&gt;    q{INSERT INTO payments (userid, cartid) VALUES ( ?, ?)},&lt;br /&gt;      $cart-&amp;gt;{userid}, $cart-&amp;gt;{cartid} &lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;die &quot;Database error: &quot; . $dbh-&amp;gt;errstr . &quot;\n&quot; if $dbh-&amp;gt;err;&lt;br /&gt;# ---------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;The question marks are SQL placeholders, which prevent SQL injection attacks. &lt;br /&gt;&lt;br /&gt;When I ran this I got the error: &apos;DBI::db=HASH(0x426eff0)-&amp;gt;do(...): attribute parameter &apos;12&apos; is not a hash ref at test.pl line 22.&apos;&lt;br /&gt;&lt;br /&gt;It seemed to be complaining that $cart-&amp;gt;{userid} is not a hash ref. I had no idea why it would want a hash ref there, but I bemusedly decided to give it what it wanted, and replaced&lt;br /&gt;&lt;br /&gt;          $cart-&amp;gt;{userid}, $cart-&amp;gt;{cartid} &lt;br /&gt;&lt;br /&gt;with:&lt;br /&gt;&lt;br /&gt;          $cart, $cart&lt;br /&gt;&lt;br /&gt;Running the script again gave an SQL error instead of a Perl error: &apos;Database error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near &apos;)&apos; at line 2&apos;.&lt;br /&gt;&lt;br /&gt;So it seems like giving it a hash ref is the right thing to do, but I&apos;m giving it the wrong kind of hash ref. I&apos;m completely confused: what&apos;s the right syntax for inserting a row into the database?&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=dw_dev_training&amp;ditemid=23103&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://dw-dev-training.dreamwidth.org/23103.html</comments>
  <category>sql</category>
  <category>database</category>
  <category>dbi</category>
  <category>perl</category>
  <lj:security>public</lj:security>
  <lj:poster>anarres</lj:poster>
  <lj:reply-count>5</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://dw-dev-training.dreamwidth.org/20879.html</guid>
  <pubDate>Sat, 26 Jun 2010 07:47:15 GMT</pubDate>
  <title>Dynamic images in Dreamwidth</title>
  <link>https://dw-dev-training.dreamwidth.org/20879.html</link>
  <description>Posted by: &lt;span lj:user=&apos;anarres&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://anarres.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://anarres.dreamwidth.org/&apos;&gt;&lt;b&gt;anarres&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This seems like it should be easy but I&apos;m really stuck. I&apos;m trying to dynamically display images - i.e. generate the image with a perl script and display it without saving it to the server.&lt;br /&gt;&lt;br /&gt;This simple example works on my Heliohost server, but not on Dreamwidth (the example is from &lt;a href=&quot;http://www.perlmonks.org/?node_id=18565&quot;&gt;http://www.perlmonks.org/?node_id=18565&lt;/a&gt;): &lt;br /&gt;&lt;br /&gt;--------test.shtml------------&lt;br /&gt;&amp;lt;img src=&amp;quot;test.cgi?size=100&amp;quot; alt=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;--------test.cgi------------&lt;br /&gt;#!/usr/bin/perl -w&lt;br /&gt;&lt;br /&gt;use strict;&lt;br /&gt;use CGI;&lt;br /&gt;use GD;&lt;br /&gt;&lt;br /&gt;my $cgi=new CGI;&lt;br /&gt;my $cgi_size=$cgi-&amp;amp;gt;param(&apos;size&apos;) || &apos;50&apos;;&lt;br /&gt;&lt;br /&gt;print &amp;amp;quot;Content-type: image/gif\n\n&amp;amp;quot;;&lt;br /&gt;my $gd=new GD::Image($cgi_size,$cgi_size);&lt;br /&gt;my $blue=$gd-&amp;amp;gt;colorAllocate(0,0,255);&lt;br /&gt;$gd-&amp;amp;gt;fill(0,0,$blue);&lt;br /&gt;binmode STDOUT; #just in case we&apos;re on NT&lt;br /&gt;print $gd-&amp;amp;gt;gif;&lt;br /&gt;------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I&apos;m stumped - has anyone got any ideas?&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=dw_dev_training&amp;ditemid=20879&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://dw-dev-training.dreamwidth.org/20879.html</comments>
  <category>images</category>
  <category>perl</category>
  <category>cgi</category>
  <lj:security>public</lj:security>
  <lj:poster>anarres</lj:poster>
  <lj:reply-count>10</lj:reply-count>
</item>
</channel>
</rss>
