<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1038227" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1038227</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/breaking-list-down#comment-1218316</link>
    <description> &lt;p&gt;Ok,&lt;br /&gt;
This is where I&#039;ve got to at the moment:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;@lines = (&amp;#039;200611&amp;#039;,&amp;#039;200612&amp;#039;,&amp;#039;200701&amp;#039;,&amp;#039;200702&amp;#039;);&lt;br /&gt;sub parse_date_line {&lt;br /&gt; /([0-9]{4})([0-9]{2})/;&lt;br /&gt; return ($1, $2);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;sub group_lines_by_year {&lt;br /&gt; @ret = (); $current_group = null;&lt;br /&gt; foreach (@_) {&lt;br /&gt; ($year, $month) = parse_date_line $_;&lt;br /&gt; if ($year != $current_group) {&lt;br /&gt; $current_group = $year;&lt;br /&gt; push (@ret, &amp;quot;&amp;lt;a href\=\&amp;quot;\#nogo\&amp;quot;&amp;gt;$year&amp;lt;\/a&amp;gt;&amp;quot;);&lt;br /&gt; }&lt;br /&gt; push (@ret, &amp;quot;&amp;lt;a href\=\&amp;quot;\#thearchivecodegoeshere\&amp;quot;&amp;gt;$month&amp;lt;\/a&amp;gt;&amp;quot;);&lt;br /&gt; }&lt;br /&gt; return @ret;&lt;br /&gt; }&lt;br /&gt; foreach (group_lines_by_year(@lines)) {&lt;br /&gt; print $_ . &amp;quot;&amp;lt;br&amp;gt;\n&amp;quot;;&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;I still have to see if I can integrate this with the rest of my code. Eventually this will be part of a small blog system (&lt;a href=&quot;http://ted-hawkins.com/dabloggo.html&quot; class=&quot;bb-url&quot;&gt;DaBloggo&lt;/a&gt;) which people will be able to download free from my site. Abhishek, you&#039;ll get listed in the credits for this (unless you don&#039;t want to be).&lt;/p&gt;
&lt;p&gt;It&#039;s all in Beta Version at the moment - so&#039;s I can get input from others and stuff right.&lt;/p&gt;
&lt;p&gt;cheers - Ted&lt;/p&gt;
 </description>
     <pubDate>Tue, 24 Apr 2007 10:49:48 +0000</pubDate>
 <dc:creator>Tedh</dc:creator>
 <guid isPermaLink="false">comment 1218316 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/breaking-list-down#comment-1218313</link>
    <description> &lt;blockquote class=&quot;bb-quote-body&quot;&gt;&lt;p&gt;&lt;strong&gt;timjpriebe;218299 wrote:&lt;/strong&gt; As someone who programs in both Perl and PHP on a regular basis, I would have to disagree with Abhishek and agree with brady.k. I&#039;ve found that for non-programmers or new programmers, PHP is much easier and simpler to pick up.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The only reason I can think of for why this can be is that documentation and support for PHP is easier to find -- including tutorials, articles and forums.  However, owning the right book or searching and asking in the right places is enough to overcome that handicap for Perl.&lt;/p&gt;
&lt;p&gt;There is very little intrinsic in either of the languages and systems that makes one easier than the other, for a newcomer.  Equally, there are parts that may be harder in one or the other.  I&#039;m not even sure libraries (standard or otherwise) really count for or against either choice, as they&#039;re roughly of the same breadth and quality.&lt;/p&gt;
&lt;p&gt;For the record, here&#039;s the function in question written in PHP:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;function &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;group_lines_by_year &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$lines&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;) {&lt;br /&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$ret &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= array(); &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$current_group &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;NULL&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&amp;nbsp; foreach (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$lines &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;as &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$line&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;preg_match&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(\&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;/([0-9]{4})([0-9]{2})/\&quot;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$line&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$matches&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$year&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$matches&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$month&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$matches&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$year&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; != &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$current_group&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$current_group&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$year&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array_push(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$ret&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$year&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array_push(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$ret&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$month&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;);&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; return &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$ret&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;;&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;It is, for all intents and purposes, exactly the same as the Perl code.  I might contend that the Perl version is less verbose and more readable too, but that&#039;s a matter of taste and style.&lt;/p&gt;
&lt;p&gt;So it&#039;s not clear that PHP is in any way advantageous here.  There&#039;s no compelling reason to make such an arbitrary switch.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Tue, 24 Apr 2007 09:23:41 +0000</pubDate>
 <dc:creator>Abhishek Reddy</dc:creator>
 <guid isPermaLink="false">comment 1218313 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/breaking-list-down#comment-1218310</link>
    <description> &lt;p&gt;I should have thought of that Abhishek. Thanks. I&#039;ll have to try and split that down so the year can have it&#039;s blank link and the months their code.&lt;/p&gt;
&lt;p&gt;As for the PHP. Learning a bit of Perl does my head in at times, to begin a whole new language . . . . aaargh!&lt;/p&gt;
&lt;p&gt;- Ted&lt;/p&gt;
 </description>
     <pubDate>Tue, 24 Apr 2007 07:40:13 +0000</pubDate>
 <dc:creator>Tedh</dc:creator>
 <guid isPermaLink="false">comment 1218310 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/breaking-list-down#comment-1218300</link>
    <description> &lt;p&gt;Sorry, I didn&#039;t mean to get everyone off topic.  I just wanted to poke at Perl a little.  I mentioned it because I think PHP is easier to read than Perl, and if that&#039;s the only real benefit, it&#039;s all the more reason to use it.  &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/wink.png&quot; title=&quot;Wink&quot; alt=&quot;Wink&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Mon, 23 Apr 2007 23:17:50 +0000</pubDate>
 <dc:creator>brady.k</dc:creator>
 <guid isPermaLink="false">comment 1218300 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/breaking-list-down#comment-1218299</link>
    <description> &lt;p&gt;As someone who programs in both Perl and PHP on a regular basis, I would have to disagree with Abhishek and agree with brady.k. I&#039;ve found that for non-programmers or new programmers, PHP is much easier and simpler to pick up.&lt;/p&gt;
&lt;p&gt;And if I had my choice, I would be programming exclusively in PHP with no Perl at all. &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Mon, 23 Apr 2007 22:21:23 +0000</pubDate>
 <dc:creator>timjpriebe</dc:creator>
 <guid isPermaLink="false">comment 1218299 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/breaking-list-down#comment-1218298</link>
    <description> &lt;p&gt;You don&#039;t &lt;em&gt;have&lt;/em&gt; to print it as I gave in my example.  You could do something like this:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;foreach (group_lines_by_year(@lines)) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print &amp;quot;&amp;lt;a href=\&amp;quot;foo\&amp;quot;&amp;gt;&amp;quot; . $_ . &amp;quot;&amp;lt;/a&amp;gt;&amp;lt;br /&amp;gt;\n&amp;quot;;&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;The point is, the function [incode]group_lines_by_year[/incode] returns a list, with which you can do anything you want.  &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
&lt;blockquote class=&quot;bb-quote-body&quot;&gt;&lt;p&gt;&lt;strong&gt;brady.k;218271 wrote:&lt;/strong&gt; (not related, but you should try PHP &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/wink.png&quot; title=&quot;Wink&quot; alt=&quot;Wink&quot; class=&quot;smiley-content&quot; /&gt;  things would be much simpler if you didn&#039;t have to code in Perl...just a thought)&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;I disagree.  The algorithm would be identical.  Its expression in PHP -- aside from Perl&#039;s shorthand regex and special variables -- would also be nearly identifcal.  The difference is negligible.  &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Mon, 23 Apr 2007 21:46:50 +0000</pubDate>
 <dc:creator>Abhishek Reddy</dc:creator>
 <guid isPermaLink="false">comment 1218298 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/breaking-list-down#comment-1218271</link>
    <description> &lt;p&gt;(not related, but you should try PHP &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/wink.png&quot; title=&quot;Wink&quot; alt=&quot;Wink&quot; class=&quot;smiley-content&quot; /&gt;  things would be much simpler if you didn&#039;t have to code in Perl...just a thought)&lt;/p&gt;
 </description>
     <pubDate>Mon, 23 Apr 2007 07:49:51 +0000</pubDate>
 <dc:creator>brady.k</dc:creator>
 <guid isPermaLink="false">comment 1218271 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/breaking-list-down#comment-1218269</link>
    <description> &lt;p&gt;Thanks Abhishek, that works great. I did a text file with several yearsmonths, read into @lines array and got a nice list.&lt;/p&gt;
&lt;p&gt;Is there a way I can add links to each element? Your code is bit tight. I did manage line breaks like so:&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;print join(&amp;quot;&amp;lt;br&amp;gt;\n&amp;quot;, group_lines_by_year(@lines)) . &amp;quot;\n&amp;quot;;&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;But couldn&#039;t get any further. &lt;/p&gt;
&lt;p&gt;The end result will reside in a list that a user can click the year or the month and an action will take place. The year link will cause the months to drop down (JS and/or CSS) and the month links will open a file.&lt;/p&gt;
&lt;p&gt;I&#039;m more a designer than programmer, but manage to get some Perl working. &lt;/p&gt;
&lt;p&gt;Thanks again - Ted&lt;/p&gt;
 </description>
     <pubDate>Mon, 23 Apr 2007 07:20:03 +0000</pubDate>
 <dc:creator>Tedh</dc:creator>
 <guid isPermaLink="false">comment 1218269 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/breaking-list-down#comment-1218259</link>
    <description> &lt;p&gt;Here&#039;s a quick attempt at it.  The function [incode]group_lines_by_year[/incode] takes an array of lines as you showed and returns an array of reorganised lines that you can print any way you like.&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;sub group_lines_by_year {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @ret = (); $current_group = null;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (@_) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /([0-9]{4})([0-9]{2})/;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ($year, $month) = ($1, $2);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($year != $current_group) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $current_group = $year;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; push (@ret, $year);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; push (@ret, $month);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return @ret;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@lines = (&amp;#039;200611&amp;#039;,&amp;#039;200612&amp;#039;,&amp;#039;200701&amp;#039;,&amp;#039;200702&amp;#039;);&lt;br /&gt;print join(&amp;quot;\n&amp;quot;, group_lines_by_year(@lines)) . &amp;quot;\n&amp;quot;;&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;It works simply by walking through every line and checking if the date is in the &quot;current group&quot;.  If it isn&#039;t, then it updates the current group.  Each year and month is collected in an array and returned.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Sun, 22 Apr 2007 22:38:38 +0000</pubDate>
 <dc:creator>Abhishek Reddy</dc:creator>
 <guid isPermaLink="false">comment 1218259 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
