<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Nano&#039;s Blog &#187; programming</title>
	<atom:link href="http://www.nanohe.net/blog/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nanohe.net/blog</link>
	<description>Hello World!</description>
	<lastBuildDate>Tue, 20 Jul 2010 09:47:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Perl trim function to strip whitespace from a string</title>
		<link>http://www.nanohe.net/blog/2010/07/perl-trim-function-to-strip-whitespace-from-a-string/</link>
		<comments>http://www.nanohe.net/blog/2010/07/perl-trim-function-to-strip-whitespace-from-a-string/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 09:47:36 +0000</pubDate>
		<dc:creator>nano</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://www.nanohe.net/blog/2010/07/perl-trim-function-to-strip-whitespace-from-a-string/</guid>
		<description><![CDATA[Perl does not have a built-in trim function. Use the subroutine below to trim whitespace (spaces and tabs) from the beginning and end of a string in Perl. This function is directly based on the Perl FAQ entry, How do I strip blank space from the beginning/end of a string?. The ltrim and rtrim functions [...]]]></description>
			<content:encoded><![CDATA[<p>Perl does not have a built-in trim function. Use the subroutine below to trim whitespace (spaces and tabs) from the beginning and end of a string in Perl. This function is directly based on the Perl FAQ entry, How do I strip blank space from the beginning/end of a string?. The ltrim and rtrim functions can trim leading or trailing whitespace. </p>
<pre class="brush: perl;">
#!/usr/bin/perl

# Declare the subroutines
sub trim($);
sub ltrim($);
sub rtrim($);

# Create a test string
my $string = &quot;  \t  Hello world!   &quot;;

# Here is how to output the trimmed text &quot;Hello world!&quot;
print trim($string).&quot;\n&quot;;
print ltrim($string).&quot;\n&quot;;
print rtrim($string).&quot;\n&quot;;

# Perl trim function to remove whitespace from the start and end of the string
sub trim($)
{
	my $string = shift;
	$string =~ s/^\s+//;
	$string =~ s/\s+$//;
	return $string;
}
# Left trim function to remove leading whitespace
sub ltrim($)
{
	my $string = shift;
	$string =~ s/^\s+//;
	return $string;
}
# Right trim function to remove trailing whitespace
sub rtrim($)
{
	my $string = shift;
	$string =~ s/\s+$//;
	return $string;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nanohe.net/blog/2010/07/perl-trim-function-to-strip-whitespace-from-a-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DateTime.parse Useage Sample</title>
		<link>http://www.nanohe.net/blog/2010/06/datetime-parse-useage-sample/</link>
		<comments>http://www.nanohe.net/blog/2010/06/datetime-parse-useage-sample/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 00:56:56 +0000</pubDate>
		<dc:creator>nano</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[cs]]></category>

		<guid isPermaLink="false">http://www.nanohe.net/blog/?p=355</guid>
		<description><![CDATA[The sample code below about how to use DateTime and how to output user defined format string otherwise concatenate each character with RegEx. 
stackoverflow.com

Use DateTime.TryParse or DateTime.Parse to parse the input string to a DateTime object (if you need an exact parse, there are also ParseExact and TryParseExact that take a format string).
You can then [...]]]></description>
			<content:encoded><![CDATA[<p>The sample code below about how to use DateTime and how to output user defined format string otherwise concatenate each character with RegEx. </p>
<p>stackoverflow.com</p>
<blockquote><p>
Use DateTime.TryParse or DateTime.Parse to parse the input string to a DateTime object (if you need an exact parse, there are also ParseExact and TryParseExact that take a format string).</p>
<p>You can then use DateTime.ToString with a custom format string that will output the exact output you want directly from DateTime objects.</p>
<p>DateTime.ToString(&#8220;yyyyMMddHHmmssff&#8221;);</p></blockquote>
<p><strong>code.cs</strong></p>
<pre class="brush: csharp;">
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace ConAppTest
{
    class Program
    {

        static void Main(string[] args)
        {
            string s1 = &quot;&quot;; // date
            string s2 = &quot;&quot;; // time
            string s3 = &quot;&quot;;
            string s4 = &quot;&quot;;
            Console.WriteLine(&quot;{0}&quot;, DateTime.Now);
            s1 = DateTime.Now.ToString();
            s3 = DateTime.Parse(s1).ToString(&quot;yyyyMMddHHmmssff&quot;);
            Console.WriteLine(&quot;{0}&quot;, s3);

            Console.WriteLine(&quot;{0}&quot;, DateTime.Now.TimeOfDay);
            s2 = DateTime.Now.TimeOfDay.ToString();
            s4 = DateTime.Parse(s2).ToString(&quot;yyyyMMddHHmmssff&quot;);
            Console.WriteLine(&quot;{0}&quot;, s4);

            Regex regex1 = new Regex(@&quot; |:|/&quot;);    //6/28/2010 2:19:21 PM
            char[] separators1 = { ' ', '/' };
            foreach (string sub1 in regex1.Split(s1))
            {
                Console.WriteLine(&quot;Word1: {0}&quot;, sub1);
            }
            // A dot (.) matches any character when used in a regular expression. You need to escape it with a backslash
            Regex regex2 = new Regex(@&quot;:|\.&quot;);  //14:19:21.8771215
            char[] separators2 = { ':', '.' };
            foreach (string sub2 in regex2.Split(s2))
            {
                Console.WriteLine(&quot;Word2: {0}&quot;, sub2);
            }
        }

    }
}
</pre>
<p><strong>output</strong></p>
<pre class="brush: csharp;">
//6/29/2010 8:52:59 AM
//2010062908525900
//08:52:59.4604208
//2010062908525946
//Word1: 6
//Word1: 29
//Word1: 2010
//Word1: 8
//Word1: 52
//Word1: 59
//Word1: AM
//Word2: 08
//Word2: 52
//Word2: 59
//Word2: 4604208
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nanohe.net/blog/2010/06/datetime-parse-useage-sample/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello World!</title>
		<link>http://www.nanohe.net/blog/2010/06/hello-world-2/</link>
		<comments>http://www.nanohe.net/blog/2010/06/hello-world-2/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 03:18:44 +0000</pubDate>
		<dc:creator>nano</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[collection]]></category>

		<guid isPermaLink="false">http://www.nanohe.net/blog/?p=352</guid>
		<description><![CDATA[Collections:
&#8220;When was the last time you spent a pleasant evening in a comfortable chair, reading a good program.&#8221;
  Jon Bentley, 1986
If you’ve been wondering about the name “C++”, now you understand. It implies “one step beyond C.”
- Thinking in C++ (2E) Bruce Eckel
]]></description>
			<content:encoded><![CDATA[<p><strong>Collections:</strong></p>
<p>&#8220;When was the last time you spent a pleasant evening in a comfortable chair, reading a good program.&#8221;<br />
  Jon Bentley, 1986</p>
<p>If you’ve been wondering about the name “C++”, now you understand. It implies “one step beyond C.”<br />
- Thinking in C++ (2E) Bruce Eckel</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nanohe.net/blog/2010/06/hello-world-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generating Fibonacci Numbers Using variable-Length Arrays</title>
		<link>http://www.nanohe.net/blog/2010/06/generating-fibonacci-numbers-using-variable-length-arrays/</link>
		<comments>http://www.nanohe.net/blog/2010/06/generating-fibonacci-numbers-using-variable-length-arrays/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 07:28:03 +0000</pubDate>
		<dc:creator>nano</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[c]]></category>

		<guid isPermaLink="false">http://www.nanohe.net/blog/?p=344</guid>
		<description><![CDATA[Variable-length arrays are legal in C since C99, but if you&#8217;re using an older compiler (or compiling as C++) they won&#8217;t work.
As a workaround, you can switch to using dynamic allocation:

typedef unsigned long long uint64; // just for convenience
uint64* Fibonacci = (uint64*)malloc(sizeof(uint64)*numFibs);
// {code here}
// then at the end:
free(Fibonacci);
return 0;

Sample:

int main()
{

	int i, numFibs;

	printf(&#34;How may Fibonacci numbers [...]]]></description>
			<content:encoded><![CDATA[<p>Variable-length arrays are legal in C since C99, but if you&#8217;re using an older compiler (or compiling as C++) they won&#8217;t work.</p>
<p>As a workaround, you can switch to using dynamic allocation:</p>
<pre class="brush: cpp;">
typedef unsigned long long uint64; // just for convenience
uint64* Fibonacci = (uint64*)malloc(sizeof(uint64)*numFibs);
// {code here}
// then at the end:
free(Fibonacci);
return 0;
</pre>
<p>Sample:</p>
<pre class="brush: cpp;">
int main()
{

	int i, numFibs;

	printf(&quot;How may Fibonacci numbers do you want (between 1 to 75)? &quot;);
	//scanf(&quot;%i&quot;, &amp;numFibs);
        numFibs = 10;

	if ( numFibs &lt; 1 || numFibs &gt; 75){
	//if ( numFibs &lt; 1 || numFibs &gt; kMaxFibs){
		printf(&quot;Bad number, sorry!\n&quot;);
		return 1;
	}

	typedef unsigned long long uint64; // just for convenience
	uint64* Fibonacci = (uint64*)malloc(sizeof(uint64)*numFibs);

	Fibonacci[0] = 0;	// by definition
	Fibonacci[1] = 1;	// ditto

	for ( i = 2; i &lt; numFibs; ++i)
		Fibonacci[i] = Fibonacci[i-2] + Fibonacci[i-1];

	for ( i = 0; i &lt; numFibs; ++i)
		printf(&quot;%11u&quot;,Fibonacci[i]);

	printf(&quot;\n&quot;);
	free(Fibonacci);
	return 0;

}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nanohe.net/blog/2010/06/generating-fibonacci-numbers-using-variable-length-arrays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CIS URL Links</title>
		<link>http://www.nanohe.net/blog/2010/06/cis-university-education-links/</link>
		<comments>http://www.nanohe.net/blog/2010/06/cis-university-education-links/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 01:08:30 +0000</pubDate>
		<dc:creator>nano</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[collection]]></category>

		<guid isPermaLink="false">http://www.nanohe.net/blog/?p=339</guid>
		<description><![CDATA[Education
http://cis.stvincent.edu/html/tutorials/index.html
C
http://publications.gbdirect.co.uk/c_book/
Standard C Library
http://www.elook.org/programming/c/
]]></description>
			<content:encoded><![CDATA[<p><strong>Education</strong></p>
<p>http://cis.stvincent.edu/html/tutorials/index.html</p>
<p><strong>C</strong></p>
<p>http://publications.gbdirect.co.uk/c_book/</p>
<p>Standard C Library</p>
<p>http://www.elook.org/programming/c/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nanohe.net/blog/2010/06/cis-university-education-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to parse multi record XML file ues XML::Simple in Perl</title>
		<link>http://www.nanohe.net/blog/2010/06/how-to-parse-multi-record-xml-file-ues-xmlsimple-in-perl/</link>
		<comments>http://www.nanohe.net/blog/2010/06/how-to-parse-multi-record-xml-file-ues-xmlsimple-in-perl/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 03:30:30 +0000</pubDate>
		<dc:creator>nano</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.nanohe.net/blog/?p=328</guid>
		<description><![CDATA[How to access multiple records 
data.xml

&#60;?xml version=&#34;1.0&#34; encoding=&#34;ISO-8859-1&#34;?&#62;
&#60;catalog&#62;
  &#60;cd country=&#34;UK&#34;&#62;
    &#60;title&#62;Hide your heart&#60;/title&#62;
    &#60;artist&#62;Bonnie Tyler&#60;/artist&#62;
    &#60;price&#62;10.0&#60;/price&#62;
  &#60;/cd&#62;
  &#60;cd country=&#34;CHN&#34;&#62;
    &#60;title&#62;Greatest Hits&#60;/title&#62;
    &#60;artist&#62;Dolly Parton&#60;/artist&#62;
    &#60;price&#62;9.99&#60;/price&#62;
  &#60;/cd&#62;
  &#60;cd country=&#34;USA&#34;&#62;
    &#60;title&#62;Hello&#60;/title&#62;
  [...]]]></description>
			<content:encoded><![CDATA[<p>How to access multiple records </p>
<p><strong>data.xml</strong></p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt;
&lt;catalog&gt;
  &lt;cd country=&quot;UK&quot;&gt;
    &lt;title&gt;Hide your heart&lt;/title&gt;
    &lt;artist&gt;Bonnie Tyler&lt;/artist&gt;
    &lt;price&gt;10.0&lt;/price&gt;
  &lt;/cd&gt;
  &lt;cd country=&quot;CHN&quot;&gt;
    &lt;title&gt;Greatest Hits&lt;/title&gt;
    &lt;artist&gt;Dolly Parton&lt;/artist&gt;
    &lt;price&gt;9.99&lt;/price&gt;
  &lt;/cd&gt;
  &lt;cd country=&quot;USA&quot;&gt;
    &lt;title&gt;Hello&lt;/title&gt;
    &lt;artist&gt;Say Hello&lt;/artist&gt;
    &lt;price&gt;0001&lt;/price&gt;
  &lt;/cd&gt;
&lt;/catalog&gt;
</pre>
<p><strong>test.pl</strong></p>
<pre class="brush: perl;">
#!/usr/bin/perl
   # use module
   use strict;
   use warnings;

   use XML::Simple;
   use Data::Dumper;

   # create object
   my $xml = new XML::Simple;

   # read XML file
   my $data = $xml-&gt;XMLin(&quot;data.xml&quot;);

   # access XML data
   # print &quot;$data-&gt;{name} is $data-&gt;{age} years old and works in the $data-&gt;{department} section\n&quot;;

  print $data-&gt;{cd}[0]{country}.&quot;\n&quot;;
  print $data-&gt;{cd}[0]{artist}.&quot;\n&quot;;
  print $data-&gt;{cd}[0]{price}.&quot;\n&quot;;
  print $data-&gt;{cd}[0]{title}.&quot;\n&quot;;
  print &quot;\n\n&quot;;
  print &quot;$data-&gt;{cd}-&gt;[0]-&gt;{country}\n&quot;;
  print &quot;$data-&gt;{cd}-&gt;[0]-&gt;{artist}\n&quot;;
  print &quot;$data-&gt;{cd}-&gt;[0]-&gt;{price}\n&quot;;
  print &quot;$data-&gt;{cd}-&gt;[0]-&gt;{title}\n&quot;;

  print &quot;\n\n&quot;;
   # print output
  print Dumper($data);
</pre>
<p>output:</p>
<pre class="brush: plain;">

D:\learning\perl&gt;t1.pl
could not find ParserDetails.ini in C:/Perl/site/lib/XML/SAX
UK
Bonnie Tyler
10.0
Hide your heart

UK
Bonnie Tyler
10.0
Hide your heart

$VAR1 = {
          'cd' =&gt; [
                    {
                      'country' =&gt; 'UK',
                      'artist' =&gt; 'Bonnie Tyler',
                      'price' =&gt; '10.0',
                      'title' =&gt; 'Hide your heart'
                    },
                    {
                      'country' =&gt; 'CHN',
                      'artist' =&gt; 'Dolly Parton',
                      'price' =&gt; '9.99',
                      'title' =&gt; 'Greatest Hits'
                    },
                    {
                      'country' =&gt; 'USA',
                      'artist' =&gt; 'Say Hello',
                      'price' =&gt; '0001',
                      'title' =&gt; 'Hello'
                    }
                  ]
        };

D:\learning\perl&gt;
</pre>
<p>References:</p>
<p>http://www.go4expert.com/forums/showthread.php?t=812</p>
<p>Tips:</p>
<p>http://www.perlmonks.org/index.pl?node_id=218480</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nanohe.net/blog/2010/06/how-to-parse-multi-record-xml-file-ues-xmlsimple-in-perl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl Practice Scripts Collection</title>
		<link>http://www.nanohe.net/blog/2010/06/318/</link>
		<comments>http://www.nanohe.net/blog/2010/06/318/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 04:57:32 +0000</pubDate>
		<dc:creator>nano</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[regexp]]></category>

		<guid isPermaLink="false">http://www.nanohe.net/blog/?p=318</guid>
		<description><![CDATA[test1.pl

#!/usr/bin/perl -w
use strict;
use warnings;

use Data::Dumper;

my $s;

$s=&#34;status MaterializeU4&#34;;

print (($s =~ /s\s.*?((MaterializeU4)?)/) ? &#34;Match\n&#34; : &#34;No Match\n&#34;);

$s=&#34;status MaterializeU4&#34;;

print (($s =~ /s\s.*?((MaterializeU4)?)/) ? &#34;Match\n&#34; : &#34;No Match\n&#34;);

$s=&#34;statusaa dMaterializeU4&#34;;

print (($s =~ /s\s.*?((MaterializeU4)?)/) ? &#34;Match\n&#34; : &#34;No Match\n&#34;);

$s=&#34;status &#60; MaterializeU4&#62;&#34;;

print (($s =~ /s\s.*?((MaterializeU4)?)/) ? &#34;Match\n&#34; : &#34;No Match\n&#34;);

$s=&#34;status VIDNAME9000 = &#60;U4 MaterializeU4()&#62;&#34;;

print (($s =~ /s\s.*?((MaterializeU4)?)/) ? &#34;Match\n&#34; : &#34;No Match\n&#34;);

# [...]]]></description>
			<content:encoded><![CDATA[<p><strong>test1.pl</strong></p>
<pre class="brush: perl;">
#!/usr/bin/perl -w
use strict;
use warnings;

use Data::Dumper;

my $s;

$s=&quot;status MaterializeU4&quot;;

print (($s =~ /s\s.*?((MaterializeU4)?)/) ? &quot;Match\n&quot; : &quot;No Match\n&quot;);

$s=&quot;status MaterializeU4&quot;;

print (($s =~ /s\s.*?((MaterializeU4)?)/) ? &quot;Match\n&quot; : &quot;No Match\n&quot;);

$s=&quot;statusaa dMaterializeU4&quot;;

print (($s =~ /s\s.*?((MaterializeU4)?)/) ? &quot;Match\n&quot; : &quot;No Match\n&quot;);

$s=&quot;status &lt; MaterializeU4&gt;&quot;;

print (($s =~ /s\s.*?((MaterializeU4)?)/) ? &quot;Match\n&quot; : &quot;No Match\n&quot;);

$s=&quot;status VIDNAME9000 = &lt;U4 MaterializeU4()&gt;&quot;;

print (($s =~ /s\s.*?((MaterializeU4)?)/) ? &quot;Match\n&quot; : &quot;No Match\n&quot;);

# I inserted another one below
$s=&quot;status VIDNAME9000 = &lt;U4 MaterializeU4()&gt;&quot;;
print (($s =~ /^status .*?((MaterializeU4)?)/) ? &quot;Match\n&quot; : &quot;No Match\n&quot;);
</pre>
<p><strong>output</strong></p>
<pre class="brush: plain;">
Match
Match
No Match
Match
Match
Match
</pre>
<p><strong>test2.pl</strong></p>
<pre class="brush: perl;">
#!/usr/bin/perl -w
use strict;
use warnings;

use Data::Dumper;
my @all_lines = (
 &quot;s 1&quot;
,&quot;b 1&quot;
,&quot;&quot;
, &quot;status VIDNAME9000 = &lt;U4 MaterializeU4()&gt;&quot;
,&quot;b 2&quot;
,&quot;&quot;
, &quot;s 3&quot;
,&quot;b 3&quot;
,&quot;&quot;

);

while (@all_lines) {
    my @block = read_block();
    print Data::Dumper-&gt;Dump([\@block]);
}
exit 0;

# Read a constant definition block from a file handle.
# void return when there is no data left in the file.
# Empty return for skippable (Materialize4U) block!!!
# Otherwise return an array ref containing lines to in the block.
sub read_block {
    my @lines = ();
    my $block_started = 0;
    my $block_ignore = 0;
    while (my $line = shift @all_lines) {
        if ($line =~ /s\s.*?((MaterializeU4)?)/){
            $block_started = 1;   # why can't execute
            $block_ignore = 1 if $1; # or is it #1?
        }
        last if $line =~ /^\s*$/ &amp;&amp; $block_started;
        push @lines, $line unless $block_ignore;
    }
    return \@lines if @lines;
    return;
}
</pre>
<p><strong>output</strong></p>
<pre class="brush: plain;">
$VAR1 = [
          [
            's 1',
            'b 1'
          ]
        ];
$VAR1 = [
          [
            'status VIDNAME9000 = &lt;U4 MaterializeU4()&gt;',
            'b 2'
          ]
        ];
$VAR1 = [
          [
            's 3',
            'b 3'
          ]
        ];
</pre>
<p><strong>test3.pl</strong></p>
<pre class="brush: perl;">
#!/usr/bin/perl -w
use strict;
use warnings;

use Data::Dumper;
my @all_lines = (
 &quot;s 1&quot;
,&quot;b 1&quot;
,&quot;&quot;
, &quot;status VIDNAME9000 = &lt;U4 MaterializeU4()&gt;&quot;
,&quot;b 2&quot;
,&quot;&quot;
, &quot;s 3&quot;
,&quot;b 3&quot;
,&quot;&quot;

);

while (@all_lines) {
    my @block = read_block();
    print Data::Dumper-&gt;Dump([\@block]);
}
exit 0;

# Read a constant definition block from a file handle.
# void return when there is no data left in the file.
# Empty return for skippable (Materialize4U) block!!!
# Otherwise return an array ref containing lines to in the block.
sub read_block {
    my @lines = ();
    my $block_started = 0;
    my $block_ignore = 0;
    while (my $line = shift @all_lines) {
        if ($line =~ /^status .*?((MaterializeU4)?)/) {
            $block_started = 1;   # why can't execute
            $block_ignore = 1 if $1; # or is it #1?
        }
        last if $line =~ /^\s*$/ &amp;&amp; $block_started;
        push @lines, $line unless $block_ignore;
    }
    return \@lines if @lines;
    return;
}
</pre>
<p><strong>output</strong></p>
<pre class="brush: plain;">
$VAR1 = [
          [
            's 1',
            'b 1'
          ]
        ];
$VAR1 = [
          [
            'status VIDNAME9000 = &lt;U4 MaterializeU4()&gt;',
            'b 2'
          ]
        ];
$VAR1 = [
          [
            's 3',
            'b 3'
          ]
        ];
</pre>
<p>Why test2.pl, test3.pl can&#8217;t skip the 2nd block content? thanks.</p>
<p>test4.pl &#8211; final</p>
<pre class="brush: perl;">
#!/usr/bin/perl -w
use strict;
use warnings;

use Data::Dumper;
my @all_lines = (
 &quot;s 1&quot;
,&quot;b 1&quot;
,&quot;&quot;
, &quot;status VIDNAME9000 = &lt;U4 MaterializeU4()&gt;&quot;
,&quot;b 2&quot;
,&quot;&quot;
, &quot;s 3&quot;
,&quot;b 3&quot;
,&quot;&quot;

);

while (@all_lines) {
    my @block = read_block();
    print Data::Dumper-&gt;Dump([\@block]);
}
exit 0;

# Read a constant definition block from a file handle.
# void return when there is no data left in the file.
# Empty return for skippable (Materialize4U) block!!!
# Otherwise return an array ref containing lines to in the block.
sub read_block {
    my @lines = ();
    my $block_started = 0;
    my $block_ignore = 0;
    while (my $line = shift @all_lines) {
        # original expression as below comment.
        # if ($line =~ /status\s.*?((MaterializeU4)?)/){
        if ($line =~ /^status\s.*?((MaterializeU4))/){
            $block_started = 1;   # why can't execute
            $block_ignore = 1 if $1; # or is it #1?
        }
        last if $line =~ /^\s*$/ &amp;&amp; $block_started;
        push @lines, $line unless $block_ignore;
    }
    return \@lines if @lines;
    return;
}
</pre>
<p>output:</p>
<pre class="brush: plain;">
$VAR1 = [
          [
            's 1',
            'b 1'
          ]
        ];
$VAR1 = [];
$VAR1 = [
          [
            's 3',
            'b 3'
          ]
        ];
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.nanohe.net/blog/2010/06/318/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>strawberry perl</title>
		<link>http://www.nanohe.net/blog/2010/04/strawberry-perl/</link>
		<comments>http://www.nanohe.net/blog/2010/04/strawberry-perl/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 12:28:48 +0000</pubDate>
		<dc:creator>nano</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.nanohe.net/blog/?p=316</guid>
		<description><![CDATA[download
http://strawberryperl.com/
pm install
open CPAN client window
input : install Encode::HanExtra (ENTER)
]]></description>
			<content:encoded><![CDATA[<p><strong>download</strong></p>
<p>http://strawberryperl.com/</p>
<p>pm install<br />
open<strong> CPAN client </strong>window<br />
input : <strong>install Encode::HanExtra</strong> (ENTER)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nanohe.net/blog/2010/04/strawberry-perl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Typeof() and GetType() in C#</title>
		<link>http://www.nanohe.net/blog/2010/03/typeof-and-gettype-in-c/</link>
		<comments>http://www.nanohe.net/blog/2010/03/typeof-and-gettype-in-c/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 02:05:14 +0000</pubDate>
		<dc:creator>nano</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[cs]]></category>

		<guid isPermaLink="false">http://www.nanohe.net/blog/?p=310</guid>
		<description><![CDATA[
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace testNameSpace
{

    class testClass
    {
        public static void Main()
        {
            System.Type type0 = typeof(int);
       [...]]]></description>
			<content:encoded><![CDATA[<pre class="brush: csharp;">
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace testNameSpace
{

    class testClass
    {
        public static void Main()
        {
            System.Type type0 = typeof(int);
            Console.WriteLine(&quot;{0}&quot;, type0);

            int i = 0;
            System.Type type1 = i.GetType();
            Console.WriteLine(&quot;{0}&quot;, type1);

        }
    }
}
</pre>
<p><strong>output</strong></p>
<blockquote><p>System.Int32<br />
System.Int32</p></blockquote>
<p><strong>More:</strong><br />
MSDN : http://msdn.microsoft.com/en-us/library/58918ffs(VS.80).aspx</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nanohe.net/blog/2010/03/typeof-and-gettype-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>pear install HTML_QuickForm</title>
		<link>http://www.nanohe.net/blog/2010/01/pear-install-html_quickform/</link>
		<comments>http://www.nanohe.net/blog/2010/01/pear-install-html_quickform/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 15:04:19 +0000</pubDate>
		<dc:creator>nano</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[php pear]]></category>

		<guid isPermaLink="false">http://www.nanohe.net/blog/?p=303</guid>
		<description><![CDATA[pear.php.net
root@mysite:~# pear install &#8211;onlyreqdeps HTML_QuickForm
PHP Warning:  Module &#8216;imap&#8217; already loaded in Unknown on line 0
PHP Warning:  Module &#8216;mcrypt&#8217; already loaded in Unknown on line 0
WARNING: &#8220;pear/HTML_QuickForm&#8221; is deprecated in favor of &#8220;pear/HTML_QuickForm2&#8243;
WARNING: &#8220;pear/HTML_Common&#8221; is deprecated in favor of &#8220;pear/HTML_Common2&#8243;
downloading HTML_QuickForm-3.2.11.tgz &#8230;
Starting to download HTML_QuickForm-3.2.11.tgz (102,201 bytes)
&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..done: 102,201 bytes
downloading HTML_Common-1.2.5.tgz &#8230;
Starting to download HTML_Common-1.2.5.tgz [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://pear.php.net/">pear.php.net</a></p>
<p>root@mysite:~# pear install &#8211;onlyreqdeps HTML_QuickForm<br />
PHP Warning:  Module &#8216;imap&#8217; already loaded in Unknown on line 0<br />
PHP Warning:  Module &#8216;mcrypt&#8217; already loaded in Unknown on line 0<br />
WARNING: &#8220;pear/HTML_QuickForm&#8221; is deprecated in favor of &#8220;pear/HTML_QuickForm2&#8243;<br />
WARNING: &#8220;pear/HTML_Common&#8221; is deprecated in favor of &#8220;pear/HTML_Common2&#8243;<br />
downloading HTML_QuickForm-3.2.11.tgz &#8230;<br />
Starting to download HTML_QuickForm-3.2.11.tgz (102,201 bytes)<br />
&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..done: 102,201 bytes<br />
downloading HTML_Common-1.2.5.tgz &#8230;<br />
Starting to download HTML_Common-1.2.5.tgz (4,585 bytes)<br />
&#8230;done: 4,585 bytes<br />
install ok: channel://pear.php.net/HTML_Common-1.2.5<br />
install ok: channel://pear.php.net/HTML_QuickForm-3.2.11<br />
root@mysite:~#</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nanohe.net/blog/2010/01/pear-install-html_quickform/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
