<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: directory code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Mon, 06 Oct 2008 12:45:26 GMT</pubDate>
    <description>DZone Snippets: directory code</description>
    <item>
      <title>basename &amp; dirname in Perl</title>
      <link>http://snippets.dzone.com/posts/show/4268</link>
      <description>These two Perl functions implement approximations of the UNIX utilities `basename` and `dirname`, though basename() automatically strips off the last extension no matter what.&lt;br /&gt;&lt;code&gt;sub basename($) {&lt;br /&gt; my $file = shift;&lt;br /&gt; $file =~ s!^(?:.*/)?(.+?)(?:\.[^.]*)?$!$1!;&lt;br /&gt; return $file;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;sub dirname($) {my $file = shift; $file =~ s!/?[^/]*/*$!!; return $file; }&lt;/code&gt;</description>
      <pubDate>Fri, 06 Jul 2007 05:49:34 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4268</guid>
      <author>Minimiscience (Guildorn Tanaleth)</author>
    </item>
    <item>
      <title>Image aggregator</title>
      <link>http://snippets.dzone.com/posts/show/4259</link>
      <description>This PHP snippet outputs the contents of a table (beginning &amp; ending tags not included) containing all the images from the current directory.&lt;br /&gt;&lt;code&gt;&lt;?PHP&lt;br /&gt; $columns = 3;&lt;br /&gt; $im = glob("*.{gif,jpg,png}", GLOB_BRACE);&lt;br /&gt; $rows = ceil(count($im) / $columns);&lt;br /&gt; for ($i = 0; $i &lt; $rows; $i++) {&lt;br /&gt;  echo "\n&lt;TR&gt;";&lt;br /&gt;  for ($j = $columns*$i; isset($im[$j]) &amp;&amp; $j - $columns*$i &lt; $columns; $j++) {&lt;br /&gt;   echo "&lt;TD&gt;$im[$j]&lt;BR&gt;&lt;IMG SRC='$im[$j]'&gt;&lt;/TD&gt;";&lt;br /&gt;  }&lt;br /&gt;  echo "&lt;/TR&gt;";&lt;br /&gt; }&lt;br /&gt;?&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 05 Jul 2007 04:08:17 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4259</guid>
      <author>Minimiscience (Guildorn Tanaleth)</author>
    </item>
  </channel>
</rss>
