﻿<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://purl.org/atom/ns#">
	<link xmlns="http://purl.org/atom/ns#" type="text/html" rel="alternate" href="http://sial.org/blog/" title="Jeremy Mates’s Blog"/>
	<title xmlns="http://purl.org/atom/ns#">Jeremy Mates’s Blog</title>
	<entry xmlns="http://purl.org/atom/ns#" xmlns:default="http://www.w3.org/1999/xhtml">
		<title xmlns="http://purl.org/atom/ns#">Indirect Object Syntax</title>
		<dc:subject>Perl</dc:subject>
		<summary xmlns="http://purl.org/atom/ns#">summary</summary>
		<content xmlns="http://purl.org/atom/ns#" mode="escaped">&lt;p&gt;In Perl, do not use: &lt;tt&gt;my $cgi = new Class;&lt;/tt&gt;&lt;/p&gt;
&lt;p&gt;Instead, always use: &lt;tt&gt;my $cgi = Class-&gt;new;&lt;/tt&gt;&lt;/p&gt;
&lt;p&gt;The section &lt;a href="http://perldoc.perl.org/perlobj.html#Indirect-Object-Syntax"&gt;Indirect Object Syntax&lt;/a&gt; in the &lt;tt&gt;perlobj&lt;/tt&gt; manual details why. While the indirect object syntax might appear “nice” or in the context of &lt;tt&gt;new&lt;/tt&gt; “be easily distinguished from a method call,” these excuses belie the danger:&lt;/p&gt;
&lt;p class="sial-block-code"&gt;&lt; &lt;a href="http://www.trout.me.uk/"&gt;mst&lt;/a&gt;&gt; 'new Class' might invoke a method, or it might
       call a sub called 'new' in the current package, or
       it might fail to parse as a bareword, depending on
       the phase of the moon.&lt;/p&gt;


&lt;!-- technorati tags start --&gt;&lt;p style="text-align:right;font-size:10px;"&gt;Technorati Tags: &lt;a href="http://www.technorati.com/tag/Perl" rel="tag"&gt;Perl&lt;/a&gt;&lt;/p&gt;&lt;!-- technorati tags end --&gt;
&lt;br /&gt;

		</content>
		<issued xmlns="http://purl.org/atom/ns#">2009-04-18T14:01:04-0700</issued>
		<link xmlns="http://purl.org/atom/ns#" type="text/html" rel="alternate" href="http://sial.org/blog/2009/04/indirect_object_syntax.html" title=""/>
		<id xmlns="http://purl.org/atom/ns#">346</id>
	</entry>
</feed>
