title: Concatenating strings in Perl with "join"
body: <p><em><strong>See Update Below</em></strong></p>
  
  <p>I am going through a whole bunch of Perl scripts that someone at my company wrote. He used <code>join</code> to concatenate strings. For example, he does this (taken hot out of a real Perl script):</p>
  
  <pre><code>$fullpath=join "", $Upload_Loc, "/", "$filename";
  </code></pre>
  
  <p>Instead of this:</p>
  
  <pre><code>$fullpath = "$Upload_Loc" . "/" . "$filename";
  </code></pre>
  
  <p>Or even just this:</p>
  
  <pre><code>$fullpath = "$Upload_Loc/$filename";
  </code></pre>
  
  <p>He's no longer here, but the people who are here tell me he concatenated strings in this way because it was somehow <em>better</em>. (They're not too clear why).</p>
  
  <p>So, why would someone use <code>join</code> in this matter over using the <code>.</code> concatenate operator, or just typing the strings together as in the third example? Is there a valid reason for this style of coding?</p>
  
  <p>I'm trying to clean up lot of the mess here, and my first thought would be to end this practice. It makes the code harder to read, and I'm sure doing a <code>join</code> is not a very efficient way to concatenate strings. However, although I've been writing scripts in Perl since version 3.x, I don't consider myself a guru because I've never had a chance to hang around with people who were better than Perl than I am and could teach me Perl's deep inner secrets. I just want to make sure that my instinct is correct here before I make a fool of myself.</p>
  
  <p>I've got better ways of doing that around here.</p>
  
  <hr>
  
  <h3>Update</h3>
  
  <p>People are getting confused. He isn't just for concatenating paths. Here's another example:</p>
  
  <pre><code>$hotfix=join "", "$app", "_", "$mod", "_", "$bld", "_", "$hf", ".zip";
  </code></pre>
  
  <p>Where as I would do something like this:</p>
  
  <pre><code>$hotfix = $app . "_"  $mod . "_" . $bld . "_" . "$hf.zip";
  </code></pre>
  
  <p>Or, more likely</p>
  
  <pre><code>$hotfix = "${app}_${mod}_${bld}_${hf}.zip";
  </code></pre>
  
  <p>Or maybe in this case, I might actually use <code>join</code> because the underscore causes problems:</p>
  
  <pre><code>$hotfix = join("_", $app, $mod, $bld, $hf) . ".zip";
  </code></pre>
  
  <p>My question is still: Is he doing something that real Perl hackers know, and a newbie like me who's been doing this for only 15 years don't know about? Do people look at me concatenating strings using <code>.</code> or just putting them in quotes and say "Ha! What a noob! I bet he owns a Macintosh too!"</p>
  
  <p>Or, does the previous guy just has a <em>unique style</em> of programming much like my son's <em>unique style</em> of driving includes running head on into trees?</p>