<?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>Filip Sergot :: Homepage &#187; Perl 6</title>
	<atom:link href="http://filip.sergot.pl/category/english/programming/perl-6/feed/" rel="self" type="application/rss+xml" />
	<link>http://filip.sergot.pl</link>
	<description>Perl, Perl 6, programming, science etc...</description>
	<lastBuildDate>Sun, 16 Sep 2012 10:21:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>modules.perl6.org and BreakDancer &#8211; next steps!</title>
		<link>http://filip.sergot.pl/english/programming/perl-6/modules-perl6-org-and-breakdancer-next-steps/</link>
		<comments>http://filip.sergot.pl/english/programming/perl-6/modules-perl6-org-and-breakdancer-next-steps/#comments</comments>
		<pubDate>Sat, 15 Sep 2012 13:48:37 +0000</pubDate>
		<dc:creator>sergot</dc:creator>
				<category><![CDATA[Perl 6]]></category>
		<category><![CDATA[en]]></category>
		<category><![CDATA[modules]]></category>
		<category><![CDATA[perl6]]></category>

		<guid isPermaLink="false">http://filip.sergot.pl/?p=182</guid>
		<description><![CDATA[About modules.perl6.org Some new variables have been added to make generating site using cron easier. Now it is updated every hour. We don&#8217;t have to worry about doing it by &#8230; <a class="readmore" href="http://filip.sergot.pl/english/programming/perl-6/modules-perl6-org-and-breakdancer-next-steps/">Continue Reading &#8594;</a>]]></description>
				<content:encoded><![CDATA[<p><strong>About modules.perl6.org</strong></p>
<p>Some new variables have been added to make generating site using <em>cron</em> easier. Now it is updated every hour. We don&#8217;t have to worry about doing it by ourselves!</p>
<p>Now it generates sites for every single module &#8211; where we can (among others) read the README file.</p>
<p>It made generating process lasts longer&#8230; but not so much (up to 5 minutes)!</p>
<pre lang="" line="1" escaped="true">real	<strong>4m36.213s</strong>
user	2m50.219s
sys	0m2.156s</pre>
<p>In the future I want to connect this project with <a title="Perl 6 Ecosystem" href="https://github.com/perl6/ecosystem" target="_blank"><strong>ecosystem</strong></a>, as it&#8217;s with current modules.perl6.org. Probably we&#8217;ll add prasing Markdown (using <a title="Text::Markdown" href="https://github.com/masak/markdown/" target="_blank">Text::Markdown</a>) and POD (as <strong><em>afiskon</em></strong> suggested &#8211; thank you!).</p>
<p>&nbsp;</p>
<p><strong>About parsing POD</strong></p>
<p>I thought that we can add a simple file browser where user can see what every file contains and the content will be parsed using <a title="Pod::To::HTML" href="https://github.com/perl6/Pod-To-HTML/" target="_blank">Pod::To:HTML</a>. Is it a good idea? Unfortunately it&#8217;ll be very slow&#8230;</p>
<p>&nbsp;</p>
<p><strong>About BreakDancer (not BreakBailador as I wrote <a title="Modules.perl6.org development process." href="http://filip.sergot.pl/perl-6/modules-perl6-org-development/">here</a>)</strong></p>
<p>Tadzik and me started <a title="BreakDancer Perl 6" href="https://github.com/sergot/BreakDancer" target="_blank">BreakDancer</a>. There are some tests, you can look at it to find out how it works for now.</p>
<p>We thought it should work like this:</p>

<div class="my_syntax_box"><span class="my_syntax_selecall"><a href="javascript:;" onclick="selectCode(this); return false;">Selec All</a> </span><span class="my_syntax_Bar">Code:</span><div class="my_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="perl6" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">use</span> BreakDancer<span style="color: #339933;">;</span>
&nbsp;
gen <span style="color: #ff0000;">&quot;/module/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">%modules</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span> template <span style="color: #ff0000;">'module.tt'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$^a</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$^b</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div></div>

<p>The first argument contains a path where BreakDancer should generate HTML documents.<br />
The second argument (%modules) contains a hash, like this one:</p>

<div class="my_syntax_box"><span class="my_syntax_selecall"><a href="javascript:;" onclick="selectCode(this); return false;">Selec All</a> </span><span class="my_syntax_Bar">Code:</span><div class="my_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="perl6" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
<span style="color: #ff0000;">&quot;Module::Name&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$a</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$b</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;Another::Module&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$a1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$b1</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div></div>

<p>and so on&#8230;</p>
<p>The third argument contains a code. What it returns will be written to HTML documents.</p>
<p>Calling &amp;gen, it should create directories named as keys of %modules and a index.htm inside them with what the third argument of &amp;gen returned. It&#8217;ll also pass values of %modules as arguments of the third &amp;gen&#8217;s argument. The &amp;template subroutine will probably use Template::Mojo and it&#8217;ll return the final HTML code to write to index.htm. Of course we&#8217;ll be able not to use Template::Mojo, in this case, simply, we shouldn&#8217;t use &amp;template.</p>
<p>Hope you&#8217;ll enjoy this! Write what you think about it.</p>
<p>&nbsp;</p>
<p>Feel free to contribute BreakDancer and <a title="modules.perl6.org written in Perl 6" href="https://github.com/sergot/modules.perl6.org" target="_blank">modules.perl6.org</a>.</p>
<p>Waiting for comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://filip.sergot.pl/english/programming/perl-6/modules-perl6-org-and-breakdancer-next-steps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Who may I talk to?</title>
		<link>http://filip.sergot.pl/english/programming/perl-6/who-may-i-talk-to/</link>
		<comments>http://filip.sergot.pl/english/programming/perl-6/who-may-i-talk-to/#comments</comments>
		<pubDate>Fri, 07 Sep 2012 13:52:30 +0000</pubDate>
		<dc:creator>sergot</dc:creator>
				<category><![CDATA[Perl 6]]></category>
		<category><![CDATA[community]]></category>
		<category><![CDATA[en]]></category>
		<category><![CDATA[perl6]]></category>

		<guid isPermaLink="false">http://filip.sergot.pl/?p=164</guid>
		<description><![CDATA[Who is who? Who should you talk to? Here&#8217;s a small list! &#160; feather.perl6.nl &#8211; Juerd, mortiz perl6 organization on github (access etc.) &#8211; TimToady, pmichaud, jnthn, sorear, moritz modules &#8230; <a class="readmore" href="http://filip.sergot.pl/english/programming/perl-6/who-may-i-talk-to/">Continue Reading &#8594;</a>]]></description>
				<content:encoded><![CDATA[<p>Who is who? Who should you talk to? Here&#8217;s a small list!</p>
<p>&nbsp;</p>
<ul>
<li>feather.perl6.nl &#8211; <strong>Juerd</strong>,<strong> mortiz</strong></li>
<li>perl6 organization on github (access etc.) &#8211; <strong>TimToady</strong>, <strong>pmichaud</strong>, <strong>jnthn</strong>, <strong>sorear</strong>, <strong>moritz</strong></li>
<li>modules (help, tips), panda &#8211; <strong>tadzik </strong></li>
<li>modules.perl6.org -<strong> tadzik</strong></li>
<li>POD &#8211; <strong>tadzik</strong></li>
<li>head rakudo&#8217;s developers &#8211; <strong>pmichaud </strong>(project leader), <strong>jnthn</strong>,<strong> moritz</strong></li>
<li>head niecza&#8217;s developer &#8211; <strong>sorear</strong></li>
<li>YAPSI &#8211; <strong>masak</strong></li>
<li>macros &#8211; <strong>masak</strong></li>
<li>p6doc -<strong> moritz</strong></li>
<li>official Perl 6 documentation, Perl  6 specification -<strong> TimToady</strong></li>
<li>p6eval &#8211; <strong>moritz</strong>,<strong> sorear</strong></li>
<li>planetsix.perl.org &#8211; <strong>[Coke]</strong></li>
<li>perl6.org -<strong> moritz</strong></li>
<li>nqp - <strong><strong>pmichaud</strong></strong>, <strong><strong><strong>jnthn</strong></strong></strong></li>
</ul>
<div>All those people you can reach visiting the <em><strong>#perl6</strong></em> channel on <em>irc.freenode.net</em> &#8211; the most helpful channel. Perhaps every your problem can be solved there and everyone will be grateful for helping you!</div>
<div></div>
<div>Remember &#8211; it&#8217;s always better to write on <em><strong>#perl6</strong></em> channel.</div>
<div></div>
<div></div>
<div>Did I forget someone or something? Please, tell me if so!</div>
<div>I hope this list should be much longer. <img src='http://filip.sergot.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </div>
]]></content:encoded>
			<wfw:commentRss>http://filip.sergot.pl/english/programming/perl-6/who-may-i-talk-to/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>modules.perl6.org development.</title>
		<link>http://filip.sergot.pl/english/programming/perl-6/modules-perl6-org-development/</link>
		<comments>http://filip.sergot.pl/english/programming/perl-6/modules-perl6-org-development/#comments</comments>
		<pubDate>Sun, 02 Sep 2012 15:20:56 +0000</pubDate>
		<dc:creator>sergot</dc:creator>
				<category><![CDATA[Perl 6]]></category>
		<category><![CDATA[en]]></category>
		<category><![CDATA[modules]]></category>
		<category><![CDATA[perl6]]></category>

		<guid isPermaLink="false">http://filip.sergot.pl/?p=134</guid>
		<description><![CDATA[modules.perl6.org is recently vigorously developed . Tadzik and me were thinking a lot about modules.perl6.org. Initially we wrote the generating script in Perl 6 (using Template::Mojo as template engine insead of HTML::Template), then &#8230; <a class="readmore" href="http://filip.sergot.pl/english/programming/perl-6/modules-perl6-org-development/">Continue Reading &#8594;</a>]]></description>
				<content:encoded><![CDATA[<p>modules.perl6.org is recently vigorously developed .</p>
<p><a title="Tadzik's profile on github" href="https://github.com/tadzik" target="_blank">Tadzik</a> and me were thinking a lot about modules.perl6.org. Initially we wrote the generating script in Perl 6 (using <em>Template::Mojo</em> as template engine insead of <em>HTML::Template</em>), then added a feature that checks if modules pass tests.  Now this script generates a site which shows if a single module was updated for last 3 moths, has README file, has tests and even if passes tests.</p>
<p>We have full backward compatibility with the current modules.perl6.org but everything is written in Perl 6.</p>
<p>It uses <a title="Tadzik's blog" href="http://ttjjss.wordpress.com/" target="_blank">tadzik</a>&#8216;s <a title="Perl 6 module smoketesting service" href="https://github.com/tadzik/emmentaler" target="_blank">emmentaler</a> to test modules which produces <em>results.json</em> file with report in JSON.</p>
<p>Our build-script creates also a <em>proto.json</em> file as a list of all modules (with all useful information).</p>
<p>&nbsp;</p>
<p>I&#8217;m happy with our current result, we made everything in Perl 6, it produces ready to use website and &#8230; it&#8217;s not as slow as we predicted.</p>
<p>Generating the whole site (without testing modules with emmentaler) takes only (almost) 2 minutes:</p>
<pre lang="" line="1" escaped="true">$ time( perl6 mkjson.p6; perl6 build.p6 )

real	<strong>1m54.360s</strong>
user	1m6.484s
sys	0m4.112s</pre>
<p>&nbsp;</p>
<p>Unfortunately using SSL in Perl 6 is not available yet, so we had to execute commands to download every single module, thus this script downloads new module or updates (<em>git pull</em>) existing one for 2 minutes &#8211; it&#8217;s  a good result I think.</p>
<p>&nbsp;</p>
<p>What about the future?</p>
<p>Here is a little roadmap:</p>
<ul>
<li>add generating page for a single module (probably we&#8217;ll be able to read README file and some information about a module &#8211; by visiting /Module::Name)</li>
<li>maybe a rating system or a medal for those modules which passes all tests, has README file, are fresh and so on</li>
<li><em>tadzik</em> and me want to create an engine for generating static webpages (maybe called BreakBailador) to create pages like modules.perl6.org &#8211; what do you think about this?</li>
</ul>
<p>&nbsp;</p>
<p>Feel free to contribute! You can find the repository <a title="Perl 6's modules list." href="https://github.com/sergot/modules.perl6.org" target="_blank"><strong>here</strong></a>.</p>
<p><a title="Perl 6 Modules List" href="http://feather.perl6.nl/~sergot/modules/" target="_blank">There</a> is current modules list generated using our script.</p>
]]></content:encoded>
			<wfw:commentRss>http://filip.sergot.pl/english/programming/perl-6/modules-perl6-org-development/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A site with a lot of examples.</title>
		<link>http://filip.sergot.pl/english/programming/perl-6/site-lot-examples/</link>
		<comments>http://filip.sergot.pl/english/programming/perl-6/site-lot-examples/#comments</comments>
		<pubDate>Sun, 22 Apr 2012 12:07:16 +0000</pubDate>
		<dc:creator>sergot</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[Perl 6]]></category>
		<category><![CDATA[en]]></category>
		<category><![CDATA[examples]]></category>
		<category><![CDATA[perl6]]></category>

		<guid isPermaLink="false">http://filip.sergot.pl/?p=100</guid>
		<description><![CDATA[Here You can find a lot of interesting examples. We work on adding there new code snippets. I think that it&#8217;s a good idea to create an external website with examples &#8230; <a class="readmore" href="http://filip.sergot.pl/english/programming/perl-6/site-lot-examples/">Continue Reading &#8594;</a>]]></description>
				<content:encoded><![CDATA[<p><a title="Perl 6 Examples" href="https://github.com/perl6/perl6-examples" target="_blank">Here</a> You can find a lot of interesting examples.</p>
<p>We work on adding there new code snippets. I think that it&#8217;s a good idea to create an external website with examples browser or something like that.</p>
<p>&nbsp;</p>
<p>We&#8217;ll see. <img src='http://filip.sergot.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://filip.sergot.pl/english/programming/perl-6/site-lot-examples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>All the possible combinations! #2</title>
		<link>http://filip.sergot.pl/english/programming/perl-6/all-the-possible-combinations-2-perl-6/</link>
		<comments>http://filip.sergot.pl/english/programming/perl-6/all-the-possible-combinations-2-perl-6/#comments</comments>
		<pubDate>Tue, 10 Apr 2012 15:45:47 +0000</pubDate>
		<dc:creator>sergot</dc:creator>
				<category><![CDATA[Perl 6]]></category>
		<category><![CDATA[brute]]></category>
		<category><![CDATA[brute-force]]></category>
		<category><![CDATA[combinations]]></category>
		<category><![CDATA[en]]></category>
		<category><![CDATA[explanation]]></category>
		<category><![CDATA[force]]></category>
		<category><![CDATA[perl6]]></category>

		<guid isPermaLink="false">http://filip.sergot.pl/?p=78</guid>
		<description><![CDATA[Hi! There is something to say about codes from All the possible combinations! #1. The first script has more lines, but it&#8217;s not as important as the principle of operation. It &#8230; <a class="readmore" href="http://filip.sergot.pl/english/programming/perl-6/all-the-possible-combinations-2-perl-6/">Continue Reading &#8594;</a>]]></description>
				<content:encoded><![CDATA[<p>Hi!</p>
<p>There is something to say about codes from <a title="All the possible combinations! #1" href="http://filip.sergot.pl/2011/09/21/combinations/" target="_blank">All the possible combinations! #1</a>.</p>
<p>The first script has more lines, but it&#8217;s not as important as the principle of operation. It goes through combinations printing individual combinations one-by-one.</p>
<p>The second one (written by <a href="http://strangelyconsistent.org/" target="_blank">masak</a>) uses <strong><a href="http://perlcabal.org/syn/S03.html#Cross_operators" target="_blank">X operator</a></strong>, so we have to wait until it ends crossing elements.</p>
<p>If You need better efficiency You should probably use the first one. I try to shorten it &#8211; if You have an idea, please leave comment or contact me.</p>
<p>&nbsp;</p>
<p>o/</p>
]]></content:encoded>
			<wfw:commentRss>http://filip.sergot.pl/english/programming/perl-6/all-the-possible-combinations-2-perl-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Files</title>
		<link>http://filip.sergot.pl/english/programming/perl-6/perl-six-6-examples-code/files/</link>
		<comments>http://filip.sergot.pl/english/programming/perl-6/perl-six-6-examples-code/files/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 15:39:45 +0000</pubDate>
		<dc:creator>sergot</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[en]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[opening]]></category>
		<category><![CDATA[operations]]></category>
		<category><![CDATA[reading]]></category>
		<category><![CDATA[writing]]></category>

		<guid isPermaLink="false">http://filip.sergot.pl/?p=62</guid>
		<description><![CDATA[In this part some info about operations on files. &#160; We should start from opening files. We can use open() to do this. Selec All Code:1 my $fh = open &#8230; <a class="readmore" href="http://filip.sergot.pl/english/programming/perl-6/perl-six-6-examples-code/files/">Continue Reading &#8594;</a>]]></description>
				<content:encoded><![CDATA[<p>In this part some info about operations on files.</p>
<p>&nbsp;</p>
<p>We should start from opening files. <img src='http://filip.sergot.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>We can use <em>open() </em>to do this.</p>

<div class="my_syntax_box"><span class="my_syntax_selecall"><a href="javascript:;" onclick="selectCode(this); return false;">Selec All</a> </span><span class="my_syntax_Bar">Code:</span><div class="my_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="perl6" style="font-family:monospace;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$fh</span> <span style="color: #339933;">=</span> open <span style="color: #ff0000;">'name.txt'</span><span style="color: #339933;">,</span> <span style="color: #339933;">:</span>r<span style="color: #339933;">;</span></pre></td></tr></table></div></div>

<p>Open() returns a filehandle, it gets argument containing file&#8217;s name, and a flag, which tells in which mode this file should be opened.</p>
<p>There are flags like those:<br />
:w &#8211; opens file in write mode<br />
:r &#8211; read mode<br />
:a &#8211; append mode</p>
<p>The next question is how to read from file. There is more than one way (it is wonderful).</p>
<p>We can use <em>slurp</em>.</p>

<div class="my_syntax_box"><span class="my_syntax_selecall"><a href="javascript:;" onclick="selectCode(this); return false;">Selec All</a> </span><span class="my_syntax_Bar">Code:</span><div class="my_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="perl6" style="font-family:monospace;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$content</span> <span style="color: #339933;">=</span> slurp <span style="color: #ff0000;">'name.txt'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># all in a variable</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@content</span> <span style="color: #339933;">=</span> slurp <span style="color: #ff0000;">'name.txt'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># all in the first element of an array</span></pre></td></tr></table></div></div>

<p>Another way is to use<em> lines</em> on filehandle( look <em>opening files</em> ) .</p>

<div class="my_syntax_box"><span class="my_syntax_selecall"><a href="javascript:;" onclick="selectCode(this); return false;">Selec All</a> </span><span class="my_syntax_Bar">Code:</span><div class="my_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="perl6" style="font-family:monospace;"><span style="color: #339933;">.</span><span style="color: #000066;">say</span> <span style="color: #b1b100;">for</span> open<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'name.txt'</span><span style="color: #339933;">,</span> <span style="color: #339933;">:</span>r<span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #006600;">lines</span><span style="color: #339933;">;</span></pre></td></tr></table></div></div>

<p>&#8230; and we can <em>get</em> a single line:</p>

<div class="my_syntax_box"><span class="my_syntax_selecall"><a href="javascript:;" onclick="selectCode(this); return false;">Selec All</a> </span><span class="my_syntax_Bar">Code:</span><div class="my_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="perl6" style="font-family:monospace;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$fh</span> <span style="color: #339933;">=</span> open <span style="color: #ff0000;">'name.txt'</span><span style="color: #339933;">,</span> <span style="color: #339933;">:</span>r<span style="color: #339933;">;</span>
<span style="color: #000066;">say</span> <span style="color: #0000ff;">$fh</span><span style="color: #339933;">.</span><span style="color: #006600;">get</span><span style="color: #339933;">;</span></pre></td></tr></table></div></div>

<p>It will print the first line. <img src='http://filip.sergot.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>We can write to files as well. Use say! <img src='http://filip.sergot.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="my_syntax_box"><span class="my_syntax_selecall"><a href="javascript:;" onclick="selectCode(this); return false;">Selec All</a> </span><span class="my_syntax_Bar">Code:</span><div class="my_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="perl6" style="font-family:monospace;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$fh</span> <span style="color: #339933;">=</span> open <span style="color: #ff0000;">'name.txt'</span><span style="color: #339933;">,</span> <span style="color: #339933;">:</span>w<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># open file</span>
<span style="color: #0000ff;">$fh</span><span style="color: #339933;">.</span><span style="color: #000066;">say</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;line&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$fh</span><span style="color: #339933;">.</span><span style="color: #006600;">close</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># close file</span></pre></td></tr></table></div></div>

<p>Done.</p>
<p>Oh, to close file use <em>close</em> on opened file handle. <img src='http://filip.sergot.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>&nbsp;</p>
<p>Hope you enjoyed.<br />
More soon. <img src='http://filip.sergot.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://filip.sergot.pl/english/programming/perl-6/perl-six-6-examples-code/files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>About &#8220;Examples&#8221;</title>
		<link>http://filip.sergot.pl/english/programming/perl-6/perl-six-6-examples-code/examples/</link>
		<comments>http://filip.sergot.pl/english/programming/perl-6/perl-six-6-examples-code/examples/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 20:59:41 +0000</pubDate>
		<dc:creator>sergot</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[en]]></category>
		<category><![CDATA[examples]]></category>
		<category><![CDATA[perl6]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http://filip.sergot.pl/?p=57</guid>
		<description><![CDATA[What is this about? Simply, I will place code snippets here from different categories. From using variables, subroutines, through junction, file operations up to IO, OO, data structures, modules and &#8230; <a class="readmore" href="http://filip.sergot.pl/english/programming/perl-6/perl-six-6-examples-code/examples/">Continue Reading &#8594;</a>]]></description>
				<content:encoded><![CDATA[<p>What is this about?</p>
<p>Simply, I will place code snippets here from different categories. From using variables, subroutines, through junction, file operations up to IO, OO, data structures, <a title="Perl6's modules" href="http://modules.perl6.org/" target="_blank">modules</a> and much more!</p>
<p>Hope it&#8217;ll help with learning and training. <img src='http://filip.sergot.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://filip.sergot.pl/english/programming/perl-6/perl-six-6-examples-code/examples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>All the possible combinations!</title>
		<link>http://filip.sergot.pl/english/programming/perl-6/combinations/</link>
		<comments>http://filip.sergot.pl/english/programming/perl-6/combinations/#comments</comments>
		<pubDate>Wed, 21 Sep 2011 18:51:45 +0000</pubDate>
		<dc:creator>sergot</dc:creator>
				<category><![CDATA[Perl 6]]></category>
		<category><![CDATA[brute-force]]></category>
		<category><![CDATA[combinations]]></category>
		<category><![CDATA[en]]></category>
		<category><![CDATA[perl6]]></category>

		<guid isPermaLink="false">http://filip.sergot.pl/?p=31</guid>
		<description><![CDATA[It&#8217;s time for Perl Six! I want to show You a simple program. What does this program? It&#8217;s very simple (as i said ). It runs through a dictionary and puts all &#8230; <a class="readmore" href="http://filip.sergot.pl/english/programming/perl-6/combinations/">Continue Reading &#8594;</a>]]></description>
				<content:encoded><![CDATA[<p>It&#8217;s time for Perl Six!</p>
<p>I want to show You a simple program.</p>
<p>What does this program? It&#8217;s very simple (as i said <img src='http://filip.sergot.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ).</p>
<p>It runs through a dictionary and puts all combinations of characters, up to the length specified in variable <em>$limit</em>.</p>

<div class="my_syntax_box"><span class="my_syntax_selecall"><a href="javascript:;" onclick="selectCode(this); return false;">Selec All</a> </span><span class="my_syntax_Bar">Code:</span><div class="my_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
</pre></td><td class="code"><pre class="perl6" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">use</span> v6<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dict</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;abc&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># dictionary - characters shouldn't be repeated</span>
<span style="color: #b1b100;">my</span> Str <span style="color: #0000ff;">$rstr</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$limit</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># maximum length</span>
&nbsp;
<span style="color: #b1b100;">loop</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$s</span> <span style="color: #339933;">=</span> rstr<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$dict</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	exit <span style="color: #cc66cc;">0</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$s</span><span style="color: #339933;">.</span><span style="color: #000066;">chars</span> <span style="color: #339933;">&gt;</span> <span style="color: #0000ff;">$limit</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">say</span> <span style="color: #0000ff;">$s</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># SUBROUTINES</span>
<span style="color: #000000; font-weight: bold;">sub</span> rstr <span style="color: #009900;">&#40;</span> Str <span style="color: #0000ff;">$d</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$fCh</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$d</span><span style="color: #339933;">.</span><span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># first character of a dictonary</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$lCh</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$d</span><span style="color: #339933;">.</span><span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$d</span><span style="color: #339933;">.</span><span style="color: #000066;">chars</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># last character of a dictonary</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$rstr</span> <span style="color: #b1b100;">eq</span> fill<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$rstr</span><span style="color: #339933;">.</span><span style="color: #000066;">chars</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$lCh</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #0000ff;">$rstr</span> <span style="color: #339933;">=</span> fill<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$rstr</span><span style="color: #339933;">.</span><span style="color: #000066;">chars</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$fCh</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$rstr</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@tmp</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$rstr</span><span style="color: #339933;">.</span><span style="color: #000066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$x</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">@tmp</span><span style="color: #339933;">.</span><span style="color: #000066;">elems</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$x</span> <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">loop</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$i</span> <span style="color: #339933;">=</span> getPos<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$d</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">@tmp</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">$x</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$i</span> <span style="color: #339933;">==</span> getPos<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$d</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$lCh</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #0000ff;">@tmp</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">$x</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$fCh</span><span style="color: #339933;">;</span>
				<span style="color: #0000ff;">$x</span><span style="color: #339933;">--;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #0000ff;">@tmp</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">$x</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$d</span><span style="color: #339933;">.</span><span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$i</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">last</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</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> <span style="color: #666666; font-style: italic;"># if program has just started</span>
		<span style="color: #0000ff;">@tmp</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$d</span><span style="color: #339933;">.</span><span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #0000ff;">$rstr</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">@tmp</span><span style="color: #339933;">.</span><span style="color: #000066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$rstr</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> fill <span style="color: #009900;">&#40;</span> Int <span style="color: #0000ff;">$len</span><span style="color: #339933;">,</span> Str <span style="color: #0000ff;">$char</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> Str <span style="color: #0000ff;">$str</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">..</span><span style="color: #0000ff;">$len</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #0000ff;">$str</span> <span style="color: #339933;">~=</span> <span style="color: #0000ff;">$char</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$str</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> getPos <span style="color: #009900;">&#40;</span> Str <span style="color: #0000ff;">$d</span><span style="color: #339933;">,</span> Str <span style="color: #0000ff;">$char</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">..</span><span style="color: #0000ff;">$d</span><span style="color: #339933;">.</span><span style="color: #000066;">chars</span> <span style="color: #339933;">-&gt;</span> <span style="color: #0000ff;">$i</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$char</span> <span style="color: #b1b100;">eq</span> <span style="color: #0000ff;">$d</span><span style="color: #339933;">.</span><span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$i</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$i</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div></div>

<p>Perl 6 isn&#8217;t as fast as we would, but in the sooner future it will be changed!</p>
<p>Have fun with all brute-force stuff! <img src='http://filip.sergot.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Greetings to <strong>#perl6</strong> channel (on freenode).</p>
<p>&nbsp;</p>
<p>PS.</p>
<p>Is there any better solution to this problem? Tell me if so! <img src='http://filip.sergot.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>&nbsp;</p>
<p>This is Masak&#8217;s solution:</p>

<div class="my_syntax_box"><span class="my_syntax_selecall"><a href="javascript:;" onclick="selectCode(this); return false;">Selec All</a> </span><span class="my_syntax_Bar">Code:</span><div class="my_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="perl6" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">multi</span> combs<span style="color: #009900;">&#40;</span><span style="color: #339933;">@,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">multi</span> combs <span style="color: #009900;">&#123;</span> combs<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@^dict</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$^n</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">X</span><span style="color: #339933;">~</span> <span style="color: #0000ff;">@dict</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#40;</span><span style="color: #339933;">.</span><span style="color: #000066;">say</span> <span style="color: #b1b100;">for</span> combs<span style="color: #009900;">&#40;</span><span style="color: #339933;">&lt;</span>c a b<span style="color: #339933;">&gt;,</span> <span style="color: #0000ff;">$_</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">for</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">..</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span></pre></td></tr></table></div></div>

<p>As You can see &#8211; Perl 6 is amazing! <img src='http://filip.sergot.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Thank You very much <a title="Carl Mäsak" href="http://strangelyconsistent.org/" target="_blank">Masak</a>!</p>
<p>&nbsp;</p>
<p><a href="http://filip.sergot.pl/2012/04/10/all-the-possible-combinations-2-perl-6/">Second part</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://filip.sergot.pl/english/programming/perl-6/combinations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
