<?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>Vidul Nikolaev Petrov &#187; Perl</title>
	<atom:link href="http://www.vidul.com/category/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.vidul.com</link>
	<description>my web space</description>
	<lastBuildDate>Fri, 09 Apr 2010 21:01:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Alphabet</title>
		<link>http://www.vidul.com/2009/10/20/the-alphabet/</link>
		<comments>http://www.vidul.com/2009/10/20/the-alphabet/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 17:35:00 +0000</pubDate>
		<dc:creator>Vidul</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[chars]]></category>

		<guid isPermaLink="false">urn:uuid:{a.guid}</guid>
		<description><![CDATA[Python


import re
&#160;
_char = re.compile&#40;r'\w'&#41;
&#160;
''.join&#40;&#91;chr&#40;i&#41; for i in xrange&#40;65,122&#41; if _char.match&#40;chr&#40;i&#41;&#41;&#93;&#41;
&#160;
# or just:
import string
&#160;
string.ascii_letters
string.ascii_lowercase
string.ascii_uppercase


Ruby


&#40;65..122&#41;.to_a.map&#123; &#124;e&#124; e.chr =~ /\w/ &#38;&#38; e.chr &#125;.compact.to_s


Perl


$chars .= chr&#40;&#41; =~ /\w/ ? chr&#40;&#41; : q&#123;&#125; for 65..122;


I don&#8217;t like the mess of Ruby, and Perl.





		
			Share this on Blinklist
		
		
			Share this on del.icio.us
		
		
			Digg this!
		
		
			Share this on Reddit
		
		
			Stumble upon something good? Share it on StumbleUpon
		
		
			Share [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Python</strong></p>
<div class="typocode">

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:arial,verdana,monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span>
&nbsp;
_char = <span style="color: #dc143c;">re</span>.<span style="color: #008000;">compile</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\w</span>'</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #483d8b;">''</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">chr</span><span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">xrange</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">65</span>,<span style="color: #ff4500;">122</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">if</span> _char.<span style="color: black;">match</span><span style="color: black;">&#40;</span><span style="color: #008000;">chr</span><span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># or just:</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">string</span>
&nbsp;
<span style="color: #dc143c;">string</span>.<span style="color: black;">ascii_letters</span>
<span style="color: #dc143c;">string</span>.<span style="color: black;">ascii_lowercase</span>
<span style="color: #dc143c;">string</span>.<span style="color: black;">ascii_uppercase</span></pre></div></div>

</div>
<p><strong>Ruby</strong></p>
<div class="typocode">

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:arial,verdana,monospace;"><span style="color:#006600; font-weight:bold;">&#40;</span>65..122<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">to_a</span>.<span style="color:#9900CC;">map</span><span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>e<span style="color:#006600; font-weight:bold;">|</span> e.<span style="color:#9900CC;">chr</span> =~ <span style="color:#006600; font-weight:bold;">/</span>\w<span style="color:#006600; font-weight:bold;">/</span> <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> e.<span style="color:#9900CC;">chr</span> <span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">compact</span>.<span style="color:#9900CC;">to_s</span></pre></div></div>

</div>
<p><strong>Perl</strong></p>
<div class="typocode">

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:arial,verdana,monospace;"><span style="color: #0000ff;">$chars</span> <span style="color: #339933;">.=</span> <span style="color: #000066;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/\w/</span> <span style="color: #339933;">?</span> <span style="color: #000066;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000066;">q</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">for</span> 65<span style="color: #339933;">..</span>122<span style="color: #339933;">;</span></pre></div></div>

</div>
<p>I don&#8217;t like the mess of Ruby, and Perl.</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.vidul.com/2009/10/20/the-alphabet/&amp;Title=The+Alphabet" rel="nofollow" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://www.vidul.com/2009/10/20/the-alphabet/&amp;title=The+Alphabet" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.vidul.com/2009/10/20/the-alphabet/&amp;title=The+Alphabet" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.vidul.com/2009/10/20/the-alphabet/&amp;title=The+Alphabet" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.vidul.com/2009/10/20/the-alphabet/&amp;title=The+Alphabet" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.vidul.com/2009/10/20/the-alphabet/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=The+Alphabet+-+http://b2l.me/bj3dt+" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.vidul.com/2009/10/20/the-alphabet/&amp;h=The+Alphabet" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.vidul.com/2009/10/20/the-alphabet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>just another perlmonks&#8217; post</title>
		<link>http://www.vidul.com/2009/02/06/just-another-perlmonks-post/</link>
		<comments>http://www.vidul.com/2009/02/06/just-another-perlmonks-post/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 10:16:00 +0000</pubDate>
		<dc:creator>Vidul</dc:creator>
				<category><![CDATA[JAPH]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">urn:uuid:{a.guid}</guid>
		<description><![CDATA[perldoc perlfaq1 &#124; perl -ne ’/((?< =”)(.+hack…(?:OR)?))/&#038;&#038;die$2.$/’ -





		
			Share this on Blinklist
		
		
			Share this on del.icio.us
		
		
			Digg this!
		
		
			Share this on Reddit
		
		
			Stumble upon something good? Share it on StumbleUpon
		
		
			Share this on Technorati
		
		
			Tweet This!
		
		
			Seed this on Newsvine
		





]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.perlmonks.org/?node_id=741818">perldoc perlfaq1 | perl -ne ’/((?< =”)(.+hack…(?:OR)?))/&#038;&#038;die$2.$/’ -</a></a></p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.vidul.com/2009/02/06/just-another-perlmonks-post/&amp;Title=just+another+perlmonks%27+post" rel="nofollow" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://www.vidul.com/2009/02/06/just-another-perlmonks-post/&amp;title=just+another+perlmonks%27+post" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.vidul.com/2009/02/06/just-another-perlmonks-post/&amp;title=just+another+perlmonks%27+post" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.vidul.com/2009/02/06/just-another-perlmonks-post/&amp;title=just+another+perlmonks%27+post" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.vidul.com/2009/02/06/just-another-perlmonks-post/&amp;title=just+another+perlmonks%27+post" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.vidul.com/2009/02/06/just-another-perlmonks-post/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=just+another+perlmonks%27+post+-+http://b2l.me/bj3t3+" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.vidul.com/2009/02/06/just-another-perlmonks-post/&amp;h=just+another+perlmonks%27+post" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.vidul.com/2009/02/06/just-another-perlmonks-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Filtering Lists</title>
		<link>http://www.vidul.com/2008/12/01/filtering-lists/</link>
		<comments>http://www.vidul.com/2008/12/01/filtering-lists/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 08:33:00 +0000</pubDate>
		<dc:creator>Vidul</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[list]]></category>

		<guid isPermaLink="false">urn:uuid:{a.guid}</guid>
		<description><![CDATA[Ruby

arr = &#40;1..10&#41;.to_a
arr.select&#123; &#124;e&#124; e % 2 != 0 &#125;

Python

arr = range&#40;1,11&#41;
&#91;e for e in arr if e % 2&#93;

Perl

@arr = &#40;1..10&#41;;
grep&#40;$_ % 2, @arr&#41;;






		
			Share this on Blinklist
		
		
			Share this on del.icio.us
		
		
			Digg this!
		
		
			Share this on Reddit
		
		
			Stumble upon something good? Share it on StumbleUpon
		
		
			Share this on Technorati
		
		
			Tweet This!
		
		
			Seed this on Newsvine
		





]]></description>
			<content:encoded><![CDATA[<p><strong>Ruby</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:arial,verdana,monospace;">arr = <span style="color:#006600; font-weight:bold;">&#40;</span>1..10<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">to_a</span>
arr.<span style="color:#CC0066; font-weight:bold;">select</span><span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>e<span style="color:#006600; font-weight:bold;">|</span> e <span style="color:#006600; font-weight:bold;">%</span> <span style="color:#006666;">2</span> != <span style="color:#006666;">0</span> <span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p><strong>Python</strong></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:arial,verdana,monospace;">arr = <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span>,<span style="color: #ff4500;">11</span><span style="color: black;">&#41;</span>
<span style="color: black;">&#91;</span>e <span style="color: #ff7700;font-weight:bold;">for</span> e <span style="color: #ff7700;font-weight:bold;">in</span> arr <span style="color: #ff7700;font-weight:bold;">if</span> e <span style="color: #66cc66;">%</span> <span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span></pre></div></div>

<p><strong>Perl</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:arial,verdana,monospace;"><span style="color:#0066ff; font-weight:bold;">@arr</span> = <span style="color:#006600; font-weight:bold;">&#40;</span>1..10<span style="color:#006600; font-weight:bold;">&#41;</span>;
grep<span style="color:#006600; font-weight:bold;">&#40;</span>$_ <span style="color:#006600; font-weight:bold;">%</span> <span style="color:#006666;">2</span>, <span style="color:#0066ff; font-weight:bold;">@arr</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.vidul.com/2008/12/01/filtering-lists/&amp;Title=Filtering+Lists" rel="nofollow" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://www.vidul.com/2008/12/01/filtering-lists/&amp;title=Filtering+Lists" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.vidul.com/2008/12/01/filtering-lists/&amp;title=Filtering+Lists" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.vidul.com/2008/12/01/filtering-lists/&amp;title=Filtering+Lists" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.vidul.com/2008/12/01/filtering-lists/&amp;title=Filtering+Lists" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.vidul.com/2008/12/01/filtering-lists/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Filtering+Lists+-+http://b2l.me/bmbmg+" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.vidul.com/2008/12/01/filtering-lists/&amp;h=Filtering+Lists" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.vidul.com/2008/12/01/filtering-lists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ultra Tiny Address Book</title>
		<link>http://www.vidul.com/2008/10/29/ultra-tiny-address-book/</link>
		<comments>http://www.vidul.com/2008/10/29/ultra-tiny-address-book/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 14:18:00 +0000</pubDate>
		<dc:creator>Vidul</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">urn:uuid:{a.guid}</guid>
		<description><![CDATA[
#!/usr/bin/perl
&#160;
$s = shift;
$&#34;  = &#34;\n&#34;;
$/  = $\;
$_  = &#60;data&#62;;
@_ = /(.*?$s.*)/gi;
&#160;
print &#34;@_\n&#34;;
&#160;
__DATA__
&#160;
me &#34;some address&#34; my_phone_here
etc...
etc...&#60;/data&#62;






		
			Share this on Blinklist
		
		
			Share this on del.icio.us
		
		
			Digg this!
		
		
			Share this on Reddit
		
		
			Stumble upon something good? Share it on StumbleUpon
		
		
			Share this on Technorati
		
		
			Tweet This!
		
		
			Seed this on Newsvine
		





]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:arial,verdana,monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/perl</span>
&nbsp;
<span style="color:#ff6633; font-weight:bold;">$s</span> = shift;
$<span style="color:#996600;">&quot;  = &quot;</span>\n<span style="color:#996600;">&quot;;
$/  = $<span style="color:#000099;">\;</span>
$_  = &lt;data&gt;;
@_ = /(.*?$s.*)/gi;
&nbsp;
print &quot;</span><span style="color:#0066ff; font-weight:bold;">@_</span>\n<span style="color:#996600;">&quot;;
&nbsp;
__DATA__
&nbsp;
me &quot;</span>some address<span style="color:#996600;">&quot; my_phone_here
etc...
etc...&lt;/data&gt;</span></pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.vidul.com/2008/10/29/ultra-tiny-address-book/&amp;Title=Ultra+Tiny+Address+Book" rel="nofollow" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://www.vidul.com/2008/10/29/ultra-tiny-address-book/&amp;title=Ultra+Tiny+Address+Book" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.vidul.com/2008/10/29/ultra-tiny-address-book/&amp;title=Ultra+Tiny+Address+Book" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.vidul.com/2008/10/29/ultra-tiny-address-book/&amp;title=Ultra+Tiny+Address+Book" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.vidul.com/2008/10/29/ultra-tiny-address-book/&amp;title=Ultra+Tiny+Address+Book" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.vidul.com/2008/10/29/ultra-tiny-address-book/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Ultra+Tiny+Address+Book+-+http://b2l.me/bmtc2+" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.vidul.com/2008/10/29/ultra-tiny-address-book/&amp;h=Ultra+Tiny+Address+Book" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.vidul.com/2008/10/29/ultra-tiny-address-book/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>downloader</title>
		<link>http://www.vidul.com/2008/06/09/downloader/</link>
		<comments>http://www.vidul.com/2008/06/09/downloader/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 09:09:00 +0000</pubDate>
		<dc:creator>Vidul</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[SA]]></category>

		<guid isPermaLink="false">urn:uuid:{a.guid}</guid>
		<description><![CDATA[
#!/usr/bin/perl
&#160;
use strict;
use warnings;
use WWW::Mechanize;
use LWP::Simple;
use Data::Dumper;
use Time::HiRes qw&#40; usleep tv_interval gettimeofday &#41;;
$&#124;++;
my $url  = shift &#124;&#124; die &#34;no url given!\n&#34;;
my $ext  = shift &#124;&#124; 'mp3'; #die &#34;no file extention given!\n&#34;;
my $mech = WWW::Mechanize-&#62;new&#40;agent=&#62;&#34;Mozilla/5.0&#34;&#41;;
my $ua   = LWP::UserAgent-&#62;new;
my %seen;
&#160;
$mech-&#62;get&#40;$url&#41;;
$ua-&#62;timeout&#40;5&#41;;
&#160;
my $links = $mech-&#62;links;
&#160;
no warnings;
my $c = 0;
for my $link &#40; @&#123;$links&#125; &#41; &#123;
  [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:arial,verdana,monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> warnings<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> WWW<span style="color: #339933;">::</span><span style="color: #006600;">Mechanize</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> LWP<span style="color: #339933;">::</span><span style="color: #006600;">Simple</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Data<span style="color: #339933;">::</span><span style="color: #006600;">Dumper</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Time<span style="color: #339933;">::</span><span style="color: #006600;">HiRes</span> <span style="color: #000066;">qw</span><span style="color: #009900;">&#40;</span> usleep tv_interval gettimeofday <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$|</span><span style="color: #339933;">++;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$url</span>  <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span> <span style="color: #339933;">||</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;no url given!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$ext</span>  <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span> <span style="color: #339933;">||</span> <span style="color: #ff0000;">'mp3'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#die &quot;no file extention given!\n&quot;;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$mech</span> <span style="color: #339933;">=</span> WWW<span style="color: #339933;">::</span><span style="color: #006600;">Mechanize</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #009900;">&#40;</span>agent<span style="color: #339933;">=&gt;</span><span style="color: #ff0000;">&quot;Mozilla/5.0&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$ua</span>   <span style="color: #339933;">=</span> LWP<span style="color: #339933;">::</span><span style="color: #006600;">UserAgent</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">%seen</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">$mech</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$ua</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">timeout</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$links</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$mech</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">links</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066;">no</span> warnings<span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$c</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$link</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">@</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$links</span><span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$url</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">$link</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">url_abs</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$res</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ua</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">head</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$http_res</span>   <span style="color: #339933;">=</span> HTTP<span style="color: #339933;">::</span><span style="color: #006600;">Response</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$res</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$abs_name</span>   <span style="color: #339933;">=</span> <span style="color: #0000ff;">$http_res</span> <span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'_rc'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'_previous'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'_headers'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'location'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$rel_name</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$abs_name</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/.+\/(.+)$/</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$local_name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$rel_name</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #0000ff;">$seen</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$local_name</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">++</span> <span style="color: #b1b100;">and</span> <span style="color: #b1b100;">next</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$rel_name</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/\Q$ext\E$/i</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #0000ff;">$rel_name</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/\%\d+/ /g</span><span style="color: #339933;">;</span>
                <span style="color: #0000ff;">$rel_name</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/(.{35}).+/$1.../</span><span style="color: #339933;">;</span>
                <span style="color: #000066;">print</span><span style="color: #009900;">&#40;</span><span style="color: #000066;">pack</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'A45'</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;[$rel_name]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;  is being downloaded ... &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$s_time</span> <span style="color: #339933;">=</span> <span style="color: #000066;">q</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$e_time</span> <span style="color: #339933;">=</span> <span style="color: #000066;">q</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$flag</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span> 1<span style="color: #339933;">..</span>5 <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                        <span style="color: #000066;">local</span> <span style="color: #0000ff;">$SIG</span><span style="color: #009900;">&#123;</span>ALRM<span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">sub</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">die</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;timeout&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
                        <span style="color: #000066;">eval</span> <span style="color: #009900;">&#123;</span>
                           <span style="color: #000066;">alarm</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                           <span style="color: #0000ff;">$flag</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>head<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$abs_name</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                           <span style="color: #000066;">alarm</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
                        <span style="color: #b1b100;">next</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$@</span> <span style="color: #339933;">=~</span> <span style="color: #000066;">m</span><span style="color: #339933;">|</span>timeout<span style="color: #339933;">|;</span>
                        <span style="color: #b1b100;">last</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$@</span> <span style="color: #339933;">!~</span> <span style="color: #000066;">m</span><span style="color: #339933;">|</span>timeout<span style="color: #339933;">|;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$flag</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                        <span style="color: #0000ff;">$c</span><span style="color: #339933;">++;</span>
                        <span style="color: #0000ff;">$s_time</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>gettimeofday<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                        getstore<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$abs_name</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$c</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$local_name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #0000ff;">$e_time</span> <span style="color: #339933;">=</span> tv_interval <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$s_time</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span>gettimeofday<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #0000ff;">$e_time</span> <span style="color: #339933;">=</span>  <span style="color: #0000ff;">$e_time</span> <span style="color: #339933;">?</span> <span style="color: #0000ff;">$e_time</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">&quot; seconds&quot;</span> <span style="color: #339933;">:</span> <span style="color: #ff0000;">'less than 1 milisecond'</span><span style="color: #339933;">;</span>
                <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;timeout failure in $e_time seconds :(<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #b1b100;">and</span> <span style="color: #b1b100;">next</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$@</span><span style="color: #339933;">;</span>
                <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;done in $e_time<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #ff0000;">`ruby -e 'Dir[&quot;*&quot;].each{|f| File.rename f, f.sub(/^<span style="color: #000099; font-weight: bold;">\d</span>+-/, &quot;&quot;)}'`</span><span style="color: #339933;">;</span>
<span style="color: #ff0000;">`ruby -e 'Dir[&quot;*&quot;].each{|f| File.rename f, f.gsub(/%20/, &quot;_&quot;)}'`</span><span style="color: #339933;">;</span></pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.vidul.com/2008/06/09/downloader/&amp;Title=downloader" rel="nofollow" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://www.vidul.com/2008/06/09/downloader/&amp;title=downloader" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.vidul.com/2008/06/09/downloader/&amp;title=downloader" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.vidul.com/2008/06/09/downloader/&amp;title=downloader" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.vidul.com/2008/06/09/downloader/&amp;title=downloader" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.vidul.com/2008/06/09/downloader/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=downloader+-+http://b2l.me/bka8j+" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.vidul.com/2008/06/09/downloader/&amp;h=downloader" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.vidul.com/2008/06/09/downloader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scalar &#124;&#124; List context</title>
		<link>http://www.vidul.com/2008/02/12/scalar-array-context/</link>
		<comments>http://www.vidul.com/2008/02/12/scalar-array-context/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 20:12:00 +0000</pubDate>
		<dc:creator>Vidul</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">urn:uuid:{a.guid}</guid>
		<description><![CDATA[Perl

 $a  = &#40;&#34;a&#34;, &#34;b&#34;, &#34;c&#34;&#41;; # $a is &#34;c&#34; - the last element
&#40;$a&#41; = &#40;&#34;a&#34;, &#34;b&#34;, &#34;c&#34;&#41;; # $a is &#34;a&#34; - the first element

Ruby

 obj        = &#91;&#34;a&#34;, &#34;b&#34;, &#34;c&#34;&#93; # obj is Array - [&#34;a&#34;, &#34;b&#34;, &#34;c&#34;]
 obj, b, c = &#91;&#34;a&#34;, &#34;b&#34;, &#34;c&#34;&#93; # [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Perl</strong></p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:arial,verdana,monospace;"> <span style="color: #0000ff;">$a</span>  <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;a&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;b&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;c&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># $a is &quot;c&quot; - the last element</span>
<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$a</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;a&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;b&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;c&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># $a is &quot;a&quot; - the first element</span></pre></div></div>

<p><strong>Ruby</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:arial,verdana,monospace;"> obj        = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;a&quot;</span>, <span style="color:#996600;">&quot;b&quot;</span>, <span style="color:#996600;">&quot;c&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#008000; font-style:italic;"># obj is Array - [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]</span>
 obj, b, c = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;a&quot;</span>, <span style="color:#996600;">&quot;b&quot;</span>, <span style="color:#996600;">&quot;c&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#008000; font-style:italic;"># obj is String - &quot;a&quot;</span></pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.vidul.com/2008/02/12/scalar-array-context/&amp;Title=Scalar+%7C%7C+List+context" rel="nofollow" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://www.vidul.com/2008/02/12/scalar-array-context/&amp;title=Scalar+%7C%7C+List+context" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.vidul.com/2008/02/12/scalar-array-context/&amp;title=Scalar+%7C%7C+List+context" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.vidul.com/2008/02/12/scalar-array-context/&amp;title=Scalar+%7C%7C+List+context" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.vidul.com/2008/02/12/scalar-array-context/&amp;title=Scalar+%7C%7C+List+context" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.vidul.com/2008/02/12/scalar-array-context/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Scalar+%7C%7C+List+context+-+http://b2l.me/bmkf9+" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.vidul.com/2008/02/12/scalar-array-context/&amp;h=Scalar+%7C%7C+List+context" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.vidul.com/2008/02/12/scalar-array-context/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl script opening (vim variant)</title>
		<link>http://www.vidul.com/2008/02/04/perl-script-opening-vim-variant/</link>
		<comments>http://www.vidul.com/2008/02/04/perl-script-opening-vim-variant/#comments</comments>
		<pubDate>Mon, 04 Feb 2008 21:57:00 +0000</pubDate>
		<dc:creator>Vidul</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">urn:uuid:{a.guid}</guid>
		<description><![CDATA[
#!/bin/bash
&#160;
file=$1
&#160;
if &#91; -e $file &#93;
then
        vim $file
else
        touch $file
        echo '#!/usr/bin/perl' &#62; $file
        echo '' &#62;&#62; $file
        echo 'use strict;' [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:arial,verdana,monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
file<span style="color: #339933;">=</span><span style="color: #0000ff;">$1</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#91;</span> <span style="color: #339933;">-</span>e <span style="color: #0000ff;">$file</span> <span style="color: #009900;">&#93;</span>
<span style="color: #b1b100;">then</span>
        vim <span style="color: #0000ff;">$file</span>
<span style="color: #b1b100;">else</span>
        touch <span style="color: #0000ff;">$file</span>
        echo <span style="color: #ff0000;">'#!/usr/bin/perl'</span> <span style="color: #339933;">&gt;</span> <span style="color: #0000ff;">$file</span>
        echo <span style="color: #ff0000;">''</span> <span style="color: #339933;">&gt;&gt;</span> <span style="color: #0000ff;">$file</span>
        echo <span style="color: #ff0000;">'use strict;'</span> <span style="color: #339933;">&gt;&gt;</span> <span style="color: #0000ff;">$file</span>
        echo <span style="color: #ff0000;">'use warnings;'</span> <span style="color: #339933;">&gt;&gt;</span> <span style="color: #0000ff;">$file</span>
        echo <span style="color: #ff0000;">'use diagnostics;'</span> <span style="color: #339933;">&gt;&gt;</span> <span style="color: #0000ff;">$file</span>
        echo <span style="color: #ff0000;">''</span> <span style="color: #339933;">&gt;&gt;</span> <span style="color: #0000ff;">$file</span>
        <span style="color: #000066;">chmod</span> <span style="color: #339933;">+</span>x <span style="color: #0000ff;">$file</span>
        vim <span style="color: #0000ff;">$file</span>
fi</pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.vidul.com/2008/02/04/perl-script-opening-vim-variant/&amp;Title=Perl+script+opening+%28vim+variant%29" rel="nofollow" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://www.vidul.com/2008/02/04/perl-script-opening-vim-variant/&amp;title=Perl+script+opening+%28vim+variant%29" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.vidul.com/2008/02/04/perl-script-opening-vim-variant/&amp;title=Perl+script+opening+%28vim+variant%29" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.vidul.com/2008/02/04/perl-script-opening-vim-variant/&amp;title=Perl+script+opening+%28vim+variant%29" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.vidul.com/2008/02/04/perl-script-opening-vim-variant/&amp;title=Perl+script+opening+%28vim+variant%29" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.vidul.com/2008/02/04/perl-script-opening-vim-variant/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Perl+script+opening+%28vim+variant%29+-+http://b2l.me/bj3ty+" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.vidul.com/2008/02/04/perl-script-opening-vim-variant/&amp;h=Perl+script+opening+%28vim+variant%29" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.vidul.com/2008/02/04/perl-script-opening-vim-variant/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JAPH with AUTOLOAD</title>
		<link>http://www.vidul.com/2008/02/03/japh-with-autoload/</link>
		<comments>http://www.vidul.com/2008/02/03/japh-with-autoload/#comments</comments>
		<pubDate>Sun, 03 Feb 2008 14:20:00 +0000</pubDate>
		<dc:creator>Vidul</dc:creator>
				<category><![CDATA[JAPH]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">urn:uuid:{a.guid}</guid>
		<description><![CDATA[
#!/usr/bin/perl
&#160;
JAPH-&#62;Just-&#62;Another-&#62;Perl-&#62;Hacker;
&#160;
package JAPH;
&#160;
sub AUTOLOAD &#123; bless &#91;print+&#40;$AUTOLOAD=~/::&#40;.+&#41;/&#41;&#91;0&#93;, q/ /&#93; &#125; sub DESTROY &#123;&#125;






		
			Share this on Blinklist
		
		
			Share this on del.icio.us
		
		
			Digg this!
		
		
			Share this on Reddit
		
		
			Stumble upon something good? Share it on StumbleUpon
		
		
			Share this on Technorati
		
		
			Tweet This!
		
		
			Seed this on Newsvine
		





]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:arial,verdana,monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
&nbsp;
JAPH<span style="color: #339933;">-&gt;</span><span style="color: #006600;">Just</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">Another</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">Perl</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">Hacker</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066;">package</span> JAPH<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> AUTOLOAD <span style="color: #009900;">&#123;</span> <span style="color: #000066;">bless</span> <span style="color: #009900;">&#91;</span><span style="color: #000066;">print</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$AUTOLOAD</span><span style="color: #339933;">=~/::</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">.+</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000066;">q</span><span style="color: #339933;">/</span> <span style="color: #339933;">/</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">sub</span> DESTROY <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span></pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.vidul.com/2008/02/03/japh-with-autoload/&amp;Title=JAPH+with+AUTOLOAD" rel="nofollow" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://www.vidul.com/2008/02/03/japh-with-autoload/&amp;title=JAPH+with+AUTOLOAD" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.vidul.com/2008/02/03/japh-with-autoload/&amp;title=JAPH+with+AUTOLOAD" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.vidul.com/2008/02/03/japh-with-autoload/&amp;title=JAPH+with+AUTOLOAD" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.vidul.com/2008/02/03/japh-with-autoload/&amp;title=JAPH+with+AUTOLOAD" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.vidul.com/2008/02/03/japh-with-autoload/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=JAPH+with+AUTOLOAD+-+http://b2l.me/bj3tx+" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.vidul.com/2008/02/03/japh-with-autoload/&amp;h=JAPH+with+AUTOLOAD" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.vidul.com/2008/02/03/japh-with-autoload/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML To WIKI converter</title>
		<link>http://www.vidul.com/2008/02/02/html-to-wiki-converter/</link>
		<comments>http://www.vidul.com/2008/02/02/html-to-wiki-converter/#comments</comments>
		<pubDate>Sat, 02 Feb 2008 12:59:00 +0000</pubDate>
		<dc:creator>Vidul</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[wiki]]></category>

		<guid isPermaLink="false">urn:uuid:{a.guid}</guid>
		<description><![CDATA[Perl script (thanks to the author of HTML::WikiConverter):

#!/usr/bin/perl
&#160;
use strict;
use warnings;
use HTML::WikiConverter;
use Perl6::Slurp;
&#160;
my $file_name = shift;
&#160;
-f $file_name or die &#34;No file given!\n&#34;;
&#160;
my $wiki = new HTML::WikiConverter&#40;dialect=&#62;'MediaWiki'&#41;;
&#160;
print $wiki-&#62;html2wiki&#40;slurp $file_name&#41;;
&#160;
__END__
&#160;
  Supported dialects:
&#160;
  DokuWiki
  Kwiki
  MediaWiki
  MoinMoin
  Oddmuse
  PbWiki
  PhpWiki
  PmWiki
  SlipSlap
  TikiWiki
  UseMod
  WakkaWiki
  [...]]]></description>
			<content:encoded><![CDATA[<p>Perl script (thanks to the author of <a href="http://search.cpan.org/~diberri/HTML-WikiConverter-0.61/lib/HTML/WikiConverter.pm">HTML::WikiConverter</a>):</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:arial,verdana,monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/perl</span>
&nbsp;
use strict;
use warnings;
use <span style="color:#6666ff; font-weight:bold;">HTML::WikiConverter</span>;
use <span style="color:#6666ff; font-weight:bold;">Perl6::Slurp</span>;
&nbsp;
my <span style="color:#ff6633; font-weight:bold;">$file_name</span> = shift;
&nbsp;
<span style="color:#006600; font-weight:bold;">-</span>f <span style="color:#ff6633; font-weight:bold;">$file_name</span> <span style="color:#9966CC; font-weight:bold;">or</span> die <span style="color:#996600;">&quot;No file given!<span style="color:#000099;">\n</span>&quot;</span>;
&nbsp;
my <span style="color:#ff6633; font-weight:bold;">$wiki</span> = new <span style="color:#6666ff; font-weight:bold;">HTML::WikiConverter</span><span style="color:#006600; font-weight:bold;">&#40;</span>dialect<span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#996600;">'MediaWiki'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;
&nbsp;
<span style="color:#CC0066; font-weight:bold;">print</span> <span style="color:#ff6633; font-weight:bold;">$wiki</span><span style="color:#006600; font-weight:bold;">-&gt;</span>html2wiki<span style="color:#006600; font-weight:bold;">&#40;</span>slurp <span style="color:#ff6633; font-weight:bold;">$file_name</span><span style="color:#006600; font-weight:bold;">&#41;</span>;
&nbsp;
__END__
&nbsp;
  Supported dialects:
&nbsp;
  DokuWiki
  Kwiki
  MediaWiki
  MoinMoin
  Oddmuse
  PbWiki
  PhpWiki
  PmWiki
  SlipSlap
  TikiWiki
  UseMod
  WakkaWiki
  WikkaWiki</pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.vidul.com/2008/02/02/html-to-wiki-converter/&amp;Title=HTML+To+WIKI+converter" rel="nofollow" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://www.vidul.com/2008/02/02/html-to-wiki-converter/&amp;title=HTML+To+WIKI+converter" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.vidul.com/2008/02/02/html-to-wiki-converter/&amp;title=HTML+To+WIKI+converter" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.vidul.com/2008/02/02/html-to-wiki-converter/&amp;title=HTML+To+WIKI+converter" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.vidul.com/2008/02/02/html-to-wiki-converter/&amp;title=HTML+To+WIKI+converter" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.vidul.com/2008/02/02/html-to-wiki-converter/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=HTML+To+WIKI+converter+-+http://b2l.me/bku95+" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.vidul.com/2008/02/02/html-to-wiki-converter/&amp;h=HTML+To+WIKI+converter" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.vidul.com/2008/02/02/html-to-wiki-converter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>File Splitter</title>
		<link>http://www.vidul.com/2008/01/18/file-splitter/</link>
		<comments>http://www.vidul.com/2008/01/18/file-splitter/#comments</comments>
		<pubDate>Sat, 19 Jan 2008 05:28:00 +0000</pubDate>
		<dc:creator>Vidul</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[split]]></category>

		<guid isPermaLink="false">urn:uuid:{a.guid}</guid>
		<description><![CDATA[
use strict;
use Getopt::Std;
use File::Basename;
&#160;
getopts&#40;'scf:p:'&#41;;
&#160;
our&#40;$opt_s, $opt_c, $opt_f, $opt_p&#41;;
&#160;
my $file = $opt_f;
my $size = $opt_p &#124;&#124; 1;
my $len  = 1024;
my $c = 1;
my &#40;$buf, $counter&#41;;
&#160;
-f $file or usage&#40;&#41;;
&#160;
if&#40;$opt_s&#41;&#123;
    $size = 1024 * $size;
&#160;
    open IN, &#34;&#60; $file&#34; or die &#34;cannot open_r $file $!&#34;;
    open OUT, &#34;&#62; $file.$c&#34; [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:arial,verdana,monospace;"><span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Getopt<span style="color: #339933;">::</span><span style="color: #006600;">Std</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> File<span style="color: #339933;">::</span><span style="color: #006600;">Basename</span><span style="color: #339933;">;</span>
&nbsp;
getopts<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'scf:p:'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">our</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$opt_s</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$opt_c</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$opt_f</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$opt_p</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$file</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$opt_f</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$size</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$opt_p</span> <span style="color: #339933;">||</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$len</span>  <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1024</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$c</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$buf</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$counter</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #339933;">-</span>f <span style="color: #0000ff;">$file</span> <span style="color: #b1b100;">or</span> usage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$opt_s</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #0000ff;">$size</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1024</span> <span style="color: #339933;">*</span> <span style="color: #0000ff;">$size</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066;">open</span> IN<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt; $file&quot;</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;cannot open_r $file $!&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">open</span> OUT<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&gt; $file.$c&quot;</span>  <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;cannot open_w $file $!&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">binmode</span> IN<span style="color: #339933;">;</span>
    <span style="color: #000066;">binmode</span> OUT<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000066;">read</span><span style="color: #009900;">&#40;</span>IN<span style="color: #339933;">,</span> <span style="color: #0000ff;">$buf</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$len</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #0000ff;">$counter</span><span style="color: #339933;">++;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$counter</span> <span style="color: #339933;">&gt;</span> <span style="color: #0000ff;">$size</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #0000ff;">$counter</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
            <span style="color: #0000ff;">$c</span><span style="color: #339933;">++;</span>
            <span style="color: #000066;">close</span> OUT<span style="color: #339933;">;</span>
            <span style="color: #000066;">open</span> OUT<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&gt; $file.$c&quot;</span>  <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;cannot open_w $file $!&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000066;">binmode</span> OUT<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066;">print</span> OUT <span style="color: #0000ff;">$buf</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elsif</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$opt_c</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@files</span> <span style="color: #339933;">=</span> <span style="color: #000066;">grep</span> <span style="color: #009900;">&#123;</span> <span style="color: #339933;">-</span>f <span style="color: #b1b100;">and</span> <span style="color: #009966; font-style: italic;">/^$file\.\d+$/</span> <span style="color: #009900;">&#125;</span> <span style="color: #000066;">glob</span> <span style="color: #ff0000;">'*'</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$newfile</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;splitter_$file&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">open</span> OUT<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&gt;&gt; $newfile&quot;</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;cannot open_w $file $!&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">binmode</span> OUT<span style="color: #339933;">;</span>
    <span style="color: #000066;">map</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">$_</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/^$file\.//</span> <span style="color: #009900;">&#125;</span> <span style="color: #0000ff;">@files</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066;">sort</span> <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$a</span><span style="color: #339933;">&lt;</span> <span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">$b</span><span style="color: #009900;">&#125;</span> <span style="color: #0000ff;">@files</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">open</span> IN<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;$file.$_&quot;</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;cannot open_r $file $!&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">binmode</span> IN<span style="color: #339933;">;</span>
        <span style="color: #000066;">print</span> OUT <span style="color: #0000ff;">$_</span> <span style="color: #b1b100;">while</span> <span style="color: #009999;">&lt;in&gt;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">close</span> IN<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    usage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> usage<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$pro</span> <span style="color: #339933;">=</span> basename<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">print</span> <span style="color: #339933;">&lt;</span> <span style="color: #339933;">&lt;</span>SQ<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">$pro</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #000066;">s</span><span style="color: #339933;">|-</span>c<span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span>p piece size <span style="color: #339933;">-</span>f filename
&nbsp;
    <span style="color: #339933;">-</span><span style="color: #000066;">s</span>    <span style="color: #000066;">split</span> a file into pieces
    <span style="color: #339933;">-</span>c    collect a file from pieces
    <span style="color: #339933;">-</span>p     chunk size <span style="color: #009900;">&#40;</span>defaults to 1MB<span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">-</span>f     file to be processed
SQ
    <span style="color: #000066;">exit</span> <span style="color: #cc66cc;">1</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p></in></pre>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.vidul.com/2008/01/18/file-splitter/&amp;Title=File+Splitter" rel="nofollow" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://www.vidul.com/2008/01/18/file-splitter/&amp;title=File+Splitter" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.vidul.com/2008/01/18/file-splitter/&amp;title=File+Splitter" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.vidul.com/2008/01/18/file-splitter/&amp;title=File+Splitter" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.vidul.com/2008/01/18/file-splitter/&amp;title=File+Splitter" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.vidul.com/2008/01/18/file-splitter/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=File+Splitter+-+http://b2l.me/bkzre+" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.vidul.com/2008/01/18/file-splitter/&amp;h=File+Splitter" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.vidul.com/2008/01/18/file-splitter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
