gugod's blog
18 October, 09:03, by gugod, machine translated from Chinese
It has been yet another great YAPC:: Asia. Big Thanks to JPA for the wonderful Event, which has been My excuse to Escape to Japan every year (GRIN).
I have uploaded My perlbrew Slide to speakerdeck.com:
(Speakerdeck looks very neat. Awesome.)
To Recap, @ rjbs 'Talk, Email Hates The Living , is very entertaining. It is stated that the Email Message and SMTP are sort of broken by Design, which means: the Standard is Super Complicated, and some is bad and implementation Simply Definition wrong from the end user perspective. I finally realized why Emacs has all those crazy inline character encoding switching mechanism - it is just an implementation of Email message format. Thanks for rjbs to implement all those Email modules, so we don't have to . Really, we don't want to.
Miyagawa released Carton , which is the Tool for bundling App-specific CPAN modules, similar to Shipwright, but Easier. It is "Bundlr for Perl", if you known Bundlr for Ruby. We had a brief Talk about using a DSL-ish file to statically describe Dependency instead of Relying on the result of running Makefie.PL , which CAN be Dynamic. But that also means the whatever-used authoring Toolkit needs to be Enhanced to put Carton in the Game.
Takesako again demo his insanely awesome Hacking skill with Win32:: GuiTest module, which is used to Automatically Solve Minesweeper. A 9x9 puzzle is Solved in only one second. I took the latter implement IDEA to attempt a (sort-of) VNC:: GuiTest module in the YAPC hackathon with [Net:: VNC] [], a Pure-Perl VNC Client implementation by @ orangeacme , but it did not quite Finish. The Image Matching module Image:: Match is doing exact Matching and natually does not reliably work with VNC. Apparently We need to Steal the awesome fuzzy Image Matcher from Sikuli :-)
I'm also surprised to Find that perlbrew is very popular in Japan, I mean, VERY. @ acotie Posted an Introduction for perlbrew and cpanm on WEB + DB PRESS Magazine, and told Me it is like a "Standard Setup" for japanese Perl hackers. I am thrilled to hear that.
As usual, I stay a few days longer after YAPC as a brief vacation. I believe I'll be missing this country very soon.
2011 YAPC:: Asia is also the perfect ending. Very grateful to JPA, Japan Perl Association is always the YAPC:: Asia identified with a bang, so I have an excuse to escape Japan every year (laughs).
The speech is perlbrew introduction , has been uploaded to the spakerdeck.com.
(Speakerdeck really simple and easy to use, like this.)
A brief summary. @ Rjbs speech " Dark Email伝said , "entertainment is too high. Clearly point out the Email / SMTP-related standards, it is rotten from the beginning of the design. Part of the standard should define the real effects do, in fact, users are the worst. According to standard practice, general users will not understand, but to make a good effect on sub-standard, so the programmers inside and outside. I finally understand why there is that in Emacs, you can switch in a single file wonderful character encoding support (half of his words can be big5, the other half is shift-jis), originally it was just nothing to support the Email Message.
Miyagawa release of Carton , is dependent app can be tied to the CPAN module packaging tool pocket, somewhat similar to the Shipwright, but much simpler. If you used the Ruby Bundlr, then this is to Perl Bundlr the. I talk to him about, to discuss how to use another file, perhaps using a DSL style of writing, to statically define the list of dependent modules, do not use the Makefile.PL , because it may be dynamic. But it also means, CPAN author-side tools require some adjustment to the effective use of Carton.
Takesako once again demonstrated his tremendous wild hacking techniques, the use of [Wind32:: GuiTest] [] wrote a self-extracting Minesweeper program. A 9x9 on a second disk as long as the finished solution. Later I used a similar concept, try to actually do the VNC:: GuiTest, with [Net:: VNC] [] module, which is written in pure Perl VNC client library, the author @ orangeacme . However, my experiment did not succeed because the image used on the Cuo group than the Image:: Match only do accurate comparison. A clear need for Sikuli fuzzy matching method used to steal over :-)
On the other hand, perlbrew in Japan, I was surprised by the prevalence of the other. @ Acotie in WEB + DB PRESS This magazine articles that describe the use of perlbrew and cpanm
gugod's blog
22 September, 11:03, machine translated from Chinese
Cornelius
6 September, 12:25, by c9s, machine translated from Chinese
using simple syntax Dancer can quickly construct a Website.
Installation Dancer:
$ Cpanm Dancer
$ Dancer-a WebApp
WebApp will produce the Structure.
A basic post route:
Cornelius
6 September, 09:21, by c9s, machine translated from Chinese
Use Plack build a simple Hello World Application is fairly simple.
First use cpanminus installed Plack.
$ Cpanm Plack
Then open the file app.psgi build the following:
Then use plackup execute him.
$ Plackup
Open your browser and enter http://localhost:5000/ to see the results.
gugod's blog
30 August, 07:33, by gugod, machine translated from Chinese
ActiveState M Phenona
ActiveState is between the old (Fourteen years ago founded) software company, has been to provide Perl and Python language package and support of key players, especially in the Windwos platform. To do is turn into the most recent PaaS, there are already early adopters of the program to provide developers, called Stackato , this set is based on CloundFoundry the real to do.
Phenona is among very young company, specializing in Linux / Perl / MySQL / Redis and other specific programs PaaS, founded just six months (identified by hit man to say that the idea of brewing has been pregnant for two years) will be acquired ActiveState , will be integrated into Stackato in.
Record identified people Daniil Kulchenko, CPAN ID: dku selfless explains Phenona principle . Package is based on Amazon EC2, and EC2 Linux Instance in and then cut out the smaller virtual host. Technology is used LXC (Linux Container) , which is similar to the FreeBSD Jail cutting way, not actually make a complete virtual machine, but cutting OS in the file, process, group, user access to other resources, to achieve similar results . This is why Phenona only supports Linux, the main reason.
With dotcloud the initial demonstration of PaaS, competition has been to multiple, such as Heroku only supports Ruby Web App application side of this service, or like Linode , Gandi VPS , Rackspace can dynamically adjust the size of the type of VPS services, have been considered on a generation of products.
The whole concept of cloud and additional, younger generations will be led by people identified as Phenona create Daniil Kulchenko, currently 15-year-old high school student. Side of the future will finish high school, while at the ActiveState part-time.
It is a Hero.


gugod's blog
30 August, 07:33, by gugod, machine translated from Chinese
Trial dotcloud
Perl circles in the last two days started sweeping up the topic is: dotcloud PaaS vendor to provide this support PSGI up. And PSGI / Plack maintenance personnel miyagawa the immediate effect of dotcloud services. New owner new atmosphere, I wish him a flourishing career endeavors.
dotcloud form provided by Perl PaaS class type Heroku, a PSGI App passed up as long as the entire catalog can be used automatically. However, unlike Heroku only supports Ruby, dotcloud support Perl / PSGI, Ruby / Rack, Python / WSGI. Because Web App using Nginx with uWSGI.
In the use of implementation will need to install a file dotcloud , the executable file is a python program using easy_install dotcloud can be installed. The instructions provide more detailed than heroku some. Ruby and python have to provide the Worker. Not the perl Worker, but surely not to wait too long.
Currently noted the following things:
- Open up the machine is EC2 Instance, through
dotcloud ssh to connect into operation. OS is Ubuntu Lucid. A lot of resources, RAM with 768 MB, / a 70G. But not the new open (a good job even into the uptime is 89 days), I do not know is that the specifications are not fixed.
- ssh into the account is not root, not
sudo . Will ask the password, but did not know the password is what the pipeline. ssh key is automatically generated into the.
- If the local directory itself is a git repository, then the code will pass the way up is to use git push.
- Perl implementation of the app is not included in ubuntu perl, but 5.12.3, on the / opt / perls, this is a perlbrew root. But the path is not perlbrew, should be installed automatically during the initial good.
- cpan dependency installation is installed to
~/perl5 to go, like the contents of this directory under the local::lib style. Look should be the implementation cpanm --installdeps --L ~/perl5 . This directive.
- Direct support for static file, do not like Heroku in config.ru in hands and feet.
Now throw up and test the App is more MoreText (but this site does not refer to the past), is basically the process went smoothly, unlike Heroku so few steps, but DotCloud greater flexibility provided beginning.
The current account registered DotCloud still need an invitation code, price list are not seen. But this is indeed packed PaaS simple and easy enough, its strength has swept the Perl community's potential (although you need to install python to use (laughs)).
In short, there is interest, you can with what they Twitter: @ dot_cloud with the blog . You can also fill out the web site Email notify you let them.


gugod's blog
30 August, 07:33, by gugod, machine translated from Chinese
Perl module Time:: Verbal
Speaking about the time into the Perl module, because that's not very satisfied with the existing, and was thus wrote a: Time:: Verbal
Currently, it functions just two points in time difference with colloquial ways. The main features are â rounding small units, and â¡ complete i18n / l10n support two.
For example, Chinese:
> perl -MTime::Verbal -E ' my $tv = Time::Verbal->new(locale => "zh-TW"); say $tv->distance(time, time + 7**$_) for 1..10;'ä¸å°ä¸åéä¸åé6 åé40 åé5 å°ææ¨å¤©9 天66 天ä¸å¹´å¤ä¸å¹´å¤
German:
> perl -MTime::Verbal -E ' my $tv = Time::Verbal->new(locale => "de"); say $tv->distance(time, time + 7**$_) for 1..10;' weniger als eine Minute eine Minute 6 Minuten 40 Minuten etwa 5 Stunden ein Tag 9 Tage 66 Tage mehr als ein Jahr mehr als ein Jahr
Hebrew:
> perl -MTime::Verbal -E ' my $tv = Time::Verbal->new(locale => "he"); say $tv->distance(time, time + 7**$_) for 1..10;' פ××ת ×××§× ××ת ××§× ××ת 6 ××§×ת 40 ××§×ת ××¢×¨× 5 שע×ת ××× ××× 9 ×××× 66 ×××× ××¢× ×©× × ××ת ××¢× ×©× × ××ת
Included more than 60 languages translated. Translation of the content is taken from the rails-i18n plan. You can also customize language translation.
Currently do this real distance is the Rails helper method is basically the distance_of_time_in_words , but not bad in this namespace can be supplemented with other parts in succession.


gugod's blog
30 August, 07:33, by gugod, machine translated from Chinese
Oral conversion time interval Perl modules
For the time interval into a "3 minutes 29 seconds ago" This colloquial narrative of modules on CPAN are four:
Time::Duration
Time::Elapsed
DateTime::Format::Duration
DateTime::Format::Human::Duration
The first two provide the function of the input is the number of seconds (for example 7240 such integers), the latter two is the DateTime::Duration object. If you do not have to meet rigorous results, and even blur some of the better, then Time::Duration::duration of this function is the best.
See more programs and output https://gist.github.com/947706
DateTime::Format::Duration of the output format is specified manually, so do not compare table.
In the time interval exceeds one hour, only Time::Duration::duration function rounding the number of units of seconds. But if you need to do I18N / L10N, but it is to win the other two mechanisms.


gugod's blog
30 August, 07:33, by gugod, machine translated from Chinese
Password Generator
shell function, stuffed .bashrc or .zshrc before use. Used pbcopy automatically cut to the clipboard contents (Mac limit). System in the case when no such instruction can be removed.
pw () { p=`perl -e 'print map { chr rand(94) + 33 } 1..16';` echo -n $p | pbcopy echo $p }
This program is produced as I:tx)C<!:'xn((AY such strong password, useful to uppercase and lowercase letters, numbers, symbols, and if you do not want so strong, you can adjust 94,33 This group of figures for example, notes 10,48, it will produce only阿拉伯数字weak password, if not the length to 16 characters, it will be 1..16 of the part into 1..12 or 1 .. 8 of the class .
If you do not automatically cut to the clipboard before the function, can actually change the alias (note that more than one -l , in order to properly output line):
alias pw="perl -le 'print map { chr rand(94) + 33 } 1..16';"
Made stand-alone program or executable file.
This code or the weight back down each time to play.
Happy New Year.


gugod's blog
28 August, 19:04, by gugod, machine translated from Chinese
ActiveState M Phenona
ActiveState is between the old (Fourteen years ago founded) software company, has been to provide Perl and Python language package and support of key players, especially in the Windwos platform. To do is turn into the most recent PaaS, there are already early adopters of the program to provide developers, called Stackato , this set is based on CloundFoundry the real to do.
Phenona is among very young company, specializing in Linux / Perl / MySQL / Redis and other specific programs PaaS, founded just six months (identified by hit man to say that the idea of brewing has been pregnant for two years) will be acquired ActiveState , will be integrated into Stackato in.
Record identified people Daniil Kulchenko, CPAN ID: dku selfless explains Phenona principle . Package is based on Amazon EC2, and EC2 Linux Instance in and then cut out the smaller virtual host. Technology is used LXC (Linux Container) , which is similar to the FreeBSD Jail cutting way, not actually make a complete virtual machine, but cutting OS in the file, process, group, user access to other resources, to achieve similar results . This is why Phenona only supports Linux, the main reason.
With dotcloud the initial demonstration of PaaS, competition has been to multiple, such as Heroku only supports Ruby Web App application side of this service, or like Linode , Gandi VPS , Rackspace can dynamically adjust the size of the type of VPS services, have been considered on a generation of products.
The whole concept of cloud and additional, younger generations will be led by people identified as Phenona create Daniil Kulchenko, currently 15-year-old high school student. Side of the future will finish high school, while at the ActiveState part-time.
It is a Hero.


gugod's blog
28 August, 19:04, by gugod, machine translated from Chinese
Trial dotcloud
Perl circles in the last two days started sweeping up the topic is: dotcloud PaaS vendor to provide this support PSGI up. And PSGI / Plack maintenance personnel miyagawa the immediate effect of dotcloud services. New owner new atmosphere, I wish him a flourishing career endeavors.
dotcloud form provided by Perl PaaS class type Heroku, a PSGI App passed up as long as the entire catalog can be used automatically. However, unlike Heroku only supports Ruby, dotcloud support Perl / PSGI, Ruby / Rack, Python / WSGI. Because Web App using Nginx with uWSGI.
In the use of implementation will need to install a file dotcloud , the executable file is a python program using easy_install dotcloud can be installed. The instructions provide more detailed than heroku some. Ruby and python have to provide the Worker. Not the perl Worker, but surely not to wait too long.
Currently noted the following things:
- Open up the machine is EC2 Instance, through
dotcloud ssh to connect into operation. OS is Ubuntu Lucid. A lot of resources, RAM with 768 MB, / a 70G. But not the new open (a good job even into the uptime is 89 days), I do not know is that the specifications are not fixed.
- ssh into the account is not root, not
sudo . Will ask the password, but did not know the password is what the pipeline. ssh key is automatically generated into the.
- If the local directory itself is a git repository, then the code will pass the way up is to use git push.
- Perl implementation of the app is not included in ubuntu perl, but 5.12.3, on the / opt / perls, this is a perlbrew root. But the path is not perlbrew, should be installed automatically during the initial good.
- cpan dependency installation is installed to
~/perl5 to go, like the contents of this directory under the local::lib style. Look should be the implementation cpanm --installdeps --L ~/perl5 . This directive.
- Direct support for static file, do not like Heroku in config.ru in hands and feet.
Now throw up and test the App is more MoreText (but this site does not refer to the past), is basically the process went smoothly, unlike Heroku so few steps, but DotCloud greater flexibility provided beginning.
The current account registered DotCloud still need an invitation code, price list are not seen. But this is indeed packed PaaS simple and easy enough, its strength has swept the Perl community's potential (although you need to install python to use (laughs)).
In short, there is interest, you can with what they Twitter: @ dot_cloud with the blog . You can also fill out the web site Email notify you let them.


gugod's blog
28 August, 19:04, by gugod, machine translated from Chinese
Perl module Time:: Verbal
Speaking about the time into the Perl module, because that's not very satisfied with the existing, and was thus wrote a: Time:: Verbal
Currently, it functions just two points in time difference with colloquial ways. The main features are â rounding small units, and â¡ complete i18n / l10n support two.
For example, Chinese:
> perl -MTime::Verbal -E ' my $tv = Time::Verbal->new(locale => "zh-TW"); say $tv->distance(time, time + 7**$_) for 1..10;'ä¸å°ä¸åéä¸åé6 åé40 åé5 å°ææ¨å¤©9 天66 天ä¸å¹´å¤ä¸å¹´å¤
German:
> perl -MTime::Verbal -E ' my $tv = Time::Verbal->new(locale => "de"); say $tv->distance(time, time + 7**$_) for 1..10;' weniger als eine Minute eine Minute 6 Minuten 40 Minuten etwa 5 Stunden ein Tag 9 Tage 66 Tage mehr als ein Jahr mehr als ein Jahr
Hebrew:
> perl -MTime::Verbal -E ' my $tv = Time::Verbal->new(locale => "he"); say $tv->distance(time, time + 7**$_) for 1..10;' פ××ת ×××§× ××ת ××§× ××ת 6 ××§×ת 40 ××§×ת ××¢×¨× 5 שע×ת ××× ××× 9 ×××× 66 ×××× ××¢× ×©× × ××ת ××¢× ×©× × ××ת
Included more than 60 languages translated. Translation of the content is taken from the rails-i18n plan. You can also customize language translation.
Currently do this real distance is the Rails helper method is basically the distance_of_time_in_words , but not bad in this namespace can be supplemented with other parts in succession.


gugod's blog
28 August, 19:04, by gugod, machine translated from Chinese
Oral conversion time interval Perl modules
For the time interval into a "3 minutes 29 seconds ago" This colloquial narrative of modules on CPAN are four:
Time::Duration
Time::Elapsed
DateTime::Format::Duration
DateTime::Format::Human::Duration
The first two provide the function of the input is the number of seconds (for example 7240 such integers), the latter two is the DateTime::Duration object. If you do not have to meet rigorous results, and even blur some of the better, then Time::Duration::duration of this function is the best.
See more programs and output https://gist.github.com/947706
DateTime::Format::Duration of the output format is specified manually, so do not compare table.
In the time interval exceeds one hour, only Time::Duration::duration function rounding the number of units of seconds. But if you need to do I18N / L10N, but it is to win the other two mechanisms.


gugod's blog
28 August, 19:04, by gugod, machine translated from Chinese
Password Generator
shell function, stuffed .bashrc or .zshrc before use. Used pbcopy automatically cut to the clipboard contents (Mac limit). System in the case when no such instruction can be removed.
pw () { p=`perl -e 'print map { chr rand(94) + 33 } 1..16';` echo -n $p | pbcopy echo $p }
This program is produced as I:tx)C<!:'xn((AY such strong password, useful to uppercase and lowercase letters, numbers, symbols, and if you do not want so strong, you can adjust 94,33 This group of figures for example, notes 10,48, it will produce only阿拉伯数字weak password, if not the length to 16 characters, it will be 1..16 of the part into 1..12 or 1 .. 8 of the class .
If you do not automatically cut to the clipboard before the function, can actually change the alias (note that more than one -l , in order to properly output line):
alias pw="perl -le 'print map { chr rand(94) + 33 } 1..16';"
Made stand-alone program or executable file.
This code or the weight back down each time to play.
Happy New Year.


Cornelius
24 July, 16:53, by c9s, machine translated from Chinese
Github often feel on the development of Perl Module README within the pod with the module file synchronization, maintaining a fairly trouble?
You can install the Module:: Install:: ReadmeMarkdownFromPod automatically module pod to markdown format readme.
Installation:
sudo cpanm Module:: Install:: ReadmeMarkdownFromPod
Use:
At Makefile.PL within:
# In Makefile.PL
use inc:: Module:: Install;
name 'Some-Module';
readme_markdown_from 'lib / Some / Module.pm';
Finally perl Makefile.PL to generate Markdown format of the Readme, can be shown in the github project page.
Cornelius
11 July, 04:53, by c9s, machine translated from Chinese
Although similar to Perl's CPAN PHP's
Pear and
Pecl repositories available.
However, both the number of Pear or Pecl kit is not much, there are many packages are Alpha or Beta state, many packages also Text only detailed document.
Pecl package: 265
Pear package number: 569
So I am curious to check a bit
Perl CPAN module number:
69899 Uploads
22954 Distributions
96895 Modules
9060 Uploaders
This figure it is too much difference compared to.
I think for several reasons, most of the PHP Programmer rare habit of uploading suite, there is no such requirement.
More than 50% PHP Programmer is to combine PHP with HTML coded, at most, will only use MySQL, so more modules can not be made into upload, even if made of sorting out kit, but not uploaded to the Pear habits.
Pear and Pecl have not really provided a good platform file, there is no regularization of the file check, so do not even talk about the document. XD
Again Pear and Pecl Unit Test does not actually upload programs, upload up all things, and not tested on different platforms, so no one can guarantee that your package is not run. Off-topic: PHPUnit is very good in fact, documents are complete, detailed, but I do not know why no one wants it to integrate Pear or Pecl.
In addition, Pear, Pecl production threshold, the extent of most of the PHP Programmer is probably quite high (?), Is not known.
Pear or Pecl I believe the platform is certainly similar
vim.org is the case - hasty way, write a lot of very unsafe, dirty program, it is even more impossible to organize the code so that we open up to improve, because enough dirty enough to unsafe, so even do not want to touch him, so we created a stalemate situation.
Registered on the account before the Pear, Pear find this file for users to register accounts things are very strict (and perhaps every one is a PHP Programmer relationship?), Pear and Pecl need to go through manual review, do you really want to upload a package, there should Bug Report, after 2min - a few days before the audit can be uploaded through the final package. (That is, if you are not careful, you do not like to mess mean XD)
CPAN
Perl's
CPAN culture very different register relative relatively free account, upload module is also free, you have to take what the name for the module can be, what kind of nonsense you want to upload the module can also (Acme :: the beginning of modules). In CPAN top, every day there are people who develop new modules, each day there are hundreds of modules to be uploaded, updated, the old module if applicable, will be replaced by the new module. On Twitter has
cpan_new account will automatically upload all the module just released, there may be a wide range of Service to write modules echo (Net:: at the beginning or WWW:: at the beginning of the module ).
Modules of information can also be easily integrated to CPAN:
In the top you can see the status for each Release, can be traced back to each version, or view the test reports, version control information, Rating, Review and more information.
Although some of the CPAN module is bad, no maintenance, but as long as the author has written test, you can directly
cpan.org see test reports, and if the module on the platform does not pass the test if the test does not installed on your system, you can ensure your system stability.
From CPAN Smoke Test your module will be on different platforms, different versions of Perl to test and generate reports to
Data:: Flow module is:
If the module dependencies for module stability was not at ease, you can also see the Dependency page to the stability of all dependent modules (such as Ruby modules are often broken dependency status):
In addition, CPAN is also the file format through the POD module to produce documents in the file of the correct Refer can be directed to the correct page, and because the structure contains a number of POD format, and therefore the file structure will be more clear, easy to read.
Cornelius
30 June, 13:00, by c9s, machine translated from Chinese
Gitalist: Git is the Web Viewer, use the Catalyst Framework as a Web client.
Git:: Fingerd: the @ rjbs written, via the finger command to query your Git Repository.
Git:: Repository: Git Repository of information can be read.
Git:: Bunch : to manage a Git Repository contains all the paths.
Git:: FastExport:: Stitch - Stitch together multiple git fast-export streams
Git:: Flux - gitflow-like in Perl.
Cornelius
25 June, 06:07, by c9s, machine translated from Chinese
Recently a number of PHP Framework Survey of Benchmark, in general it seems most of the PHP Framework of the Hello Word, or if not open cache is not prefork apache worker, Requests per second is generally from 20 to 40 or 100 to 200 of the data are. As we leave alone open the Cache.
So take a look at
Perl . Yes, yes, that is you in the eyes of the old CGI Perl.
But today has been different. Since Japan's Super Hacker
Miyagawa wrote in early 2009
PSGI Spec version 1.0.
Plack 's really done has been in active development by the world's attention.
Perl is different from PHP, is the first in the Server starts, all the code will be compiled into memory, Request comes in, can quickly executed, and PHP does not open in the cache, the Request is to be re-read each file interpreter PHP.
Plack
Perl world Plack, basically identical Rack Ruby's role, but also with the role in the Python WSGI. For Plack other issues, you can refer to Miyagawa written
PSGI FAQ .
Use Plack, simple
Plack Server (No Cache or Prefork) can
make the
Hello Word to 4000 req / s results, simply, is more than a hundred times in PHP, and PHP was through Prefork or only way to achieve this Worker effect.
Taken from Miyagawa's blog:
We'll show more numbers once everything gets stable, but so far the number seems promising and very interesting. Simple Hello World is now 4000 req / s with Standalone server with keep-alive on, and 2MB photo file serving runs fastest on AnyEvent server (300 req / s) with sendfile (2) and AIO enabled while other dumb implementation suffers from I / O in the perl land like (80 req / s).
Also mentioned Miyagawa,
2MB image file server, then use AnyEvent can reach 300 req / s. Perl actually do the other may only reach 80 req / s.
Starman
Then look Starman. CPAN top of the Description says:
Starman - High-performance preforking PSGI / Plack web server
The Starman's performance is as follows (
taken from CPAN ):
Here's a Simple Benchmark using Hello.psgi .
- Server: Starman (workers = 10)
Requests per second: 6849.16
- Server: Twiggy
Requests per second: 3911.78
- Server: AnyEvent:: HTTPD
Requests per second: 2738.49
- Server: HTTP:: Server
gugod's blog
16 June, 01:31, by gugod, machine translated from Chinese
ActiveState is the Inter-old (founded fourteen years ago) software company, has been providing language Perl and Python packages and support the key players, especially in the Windwos platform. To do is turn into the most recent PaaS, early adopters are already programs offers developers, called Stackato , this set is based on CloundFoundry the real to do.
Phenona is among very young company, specializing in Linux / Perl / MySQL / Redis specific programs such as PaaS, founded just six months (depending on record to say that distinguish human thought has been brewing for two years pregnant) to be ActiveState acquisition , will be integrated into Stackato in.
Chong identified people Daniil Kulchenko, CPAN ID: dku Phenona explained the principle of selflessness . In fact, the package is based on Amazon EC2, and another in EC2 Linux Instance cut out in a smaller virtual host. Technology is used by LXC (Linux Container) , which is similar to FreeBSD Jail cutting way, not actually make a complete virtual machine, but cutting OS in the file, process, group, user access to other resources, to achieve similar results . This is why Linux only supports the main reason Phenona.
With dotcloud start, the competition has been evident PaaS to diversity, such as Heroku only supports Ruby Web App application side of this service, or like Linode , Gandi VPS , Rackspace can dynamically adjust the size of such VPS services, have been regarded as the last generation of product.
The whole concept of cloud and additional, younger generation will be dominated, people identified as Phenona record Daniil Kulchenko, currently 15-year-old high school student. Side of the future will finish high school, while at the ActiveState part-time.
It is the Young Hero.


gugod's blog
14 June, 01:56, by gugod, machine translated from Chinese
In the Terminal in, [@ audreyt] [] written [App:: Uni] [] is a Unicode character can be used utility queries:

Basically tantamount to grep [UnicodeData.txt] []
Yesterday, rewrite a bit, wrote a very simple Web App: Uni lost to [dotcloud] [] placed

The best use of such tools is to search a variety of symbols used, especially now that Unicode 6.0 has emoticon (from the Japanese mobile phone manufacturers to provide the text Yen symbol), but the moment there is complete coverage of the Unicode 6.0 font file literally, but also really did not. Only to find a set of [Symbola] [] fonts have all the emoticons (HE), the original author's site, there are many other ancient words of the font, the font file is not generally built to provide the parts.
The word free, and open licensing is very simple, what restrictions do not:
Fonts in this site are offered free for any use; they may be opened, edited, modified, regenerated, posted, packaged and redistributed.
This set of fonts installed, you can see the page in the Uni Yan text symbols.
If people think it would look good painted, installed sets [fontforge] [] to be changed


gugod's blog
8 June, 14:33, by gugod, machine translated from Chinese
Briefly explains the Trinity of perlbrew , patchperl , and cpanm http://www.perlbrew.pl/Perlbrew-and-Friends.html
Explain a bit later perlbrew , patchperl , cpanm between http://www.perlbrew.pl/Perlbrew-and-Friends.html


gugod's blog
8 June, 14:33, by gugod, machine translated from Chinese
Briefly explains the Trinity of perlbrew , patchperl , and cpanm http://www.perlbrew.pl/Perlbrew-and-Friends.html
Explain a bit later perlbrew , patchperl , cpanm between http://www.perlbrew.pl/Perlbrew-and-Friends.html
gugod's blog
2 June, 23:50, by gugod, machine translated from Chinese
See a warning message when this line:
Math::BigInt: couldn't load specified math lib(s), fallback to Math::BigInt::FastCal
To install one of the following two modules
cpanm Math::BigInt::GMP cpanm Math::BigInt::Pari
MacOS 10.6 currently tops Math::BigInt::Pari no problem, but if the Homebrew with the gmp, the method of loading no Math::BigInt::GMP . Gmp version seems to be because too new.


gugod's blog
2 June, 23:50, by gugod, machine translated from Chinese
See a warning message when this line:
Math::BigInt: couldn't load specified math lib(s), fallback to Math::BigInt::FastCal
To install one of the following two modules
cpanm Math::BigInt::GMP cpanm Math::BigInt::Pari
MacOS 10.6 currently tops Math::BigInt::Pari no problem, but if the Homebrew with the gmp, the method of loading no Math::BigInt::GMP . Gmp version seems to be because too new.
gugod's blog
1 May, 04:20, by gugod, machine translated from Chinese
Perl circles in recent days began sweeping up the topic is: dotcloud PaaS vendor to provide this support PSGI out. And PSGI / Plack's maintenance personnel miyagawa will with immediate effect as dotcloud services. New owner new atmosphere, I wish him a flourishing career.
dotcloud Perl PaaS in the form provided by the class type Heroku, a PSGI App just passed up the entire directory can be used automatically. However, unlike Heroku only supports Ruby, dotcloud support Perl / PSGI, Ruby / Rack, Python / WSGI. Because Web App using Nginx with uWSGI.
In the use of the implementation will need to install a file dotcloud , the executable file is a python program, with the easy_install dotcloud can be installed. The directive provides much more detailed than heroku some. Ruby and python have provided the Worker. No perl in the Worker, but it surely does not need to wait too long.
Currently noted the following things:
- Open up the machine is EC2 Instance, through
dotcloud ssh can not even go in operation. OS is Ubuntu Lucid. Lot of resources, RAM has 768 MB, / a 70G. But not the new open (a good start even go uptime is 89 days), I do not know is that the specifications are not fixed.
- ssh into the account is not root, not
sudo . Will ask the password, but did not know the password what pipe. ssh key is automatically generated into the.
- If the local directory itself is a git repository, then the code will pass the way up is to use git push.
- Implementation of the perl app included with ubuntu is not perl, but 5.12.3, on the / opt / perls, this is a perlbrew root. But the path is not perlbrew, should be installed automatically during the initial good.
- cpan dependency of the installation is installed to
~/perl5 to go, like the contents of this directory under the local::lib style. Should look the implementation of cpanm --installdeps --L ~/perl5 . this instruction.
- Direct support static file, not in the hands as Heroku in config.ru feet.
Now go test the App is lost and the number of MoreText (but this site does not refer to the past), is basically the process went smoothly, unlike the Heroku so few steps, but DotCloud greater flexibility to provide the beginning.
The current account registered DotCloud still need an invitation code, price list are not seen. But this really enough PaaS packed easy to use, the strength of the trend has swept the Perl community (though you need to install python to use (laughs)).
In short, are interested, you can with what they Twitter: @ dot_cloud with the blog . You can also fill out the Email Web site to notify you let them.


gugod's blog
1 May, 04:20, by gugod, machine translated from Chinese
Perl circles in the last two days started sweeping up the topic is: dotcloud PaaS vendor to provide this support PSGI out. And PSGI / Plack's maintenance personnel miyagawa will with immediate effect as dotcloud services. New owner new atmosphere, I wish him a flourishing career.
dotcloud Perl PaaS in the form provided by the class type Heroku, a PSGI App just passed up the entire directory can be used automatically. However, unlike Heroku only supports Ruby, dotcloud support Perl / PSGI, Ruby / Rack, Python / WSGI. Because Web App using Nginx with uWSGI.
In the use of the implementation will need to install a file dotcloud , the executable file is a python program, with the easy_install dotcloud can be installed. The directive provides much more detailed than heroku some. Ruby and python have provided the Worker. No perl in the Worker, but it surely does not need to wait too long.
Currently noted the following things:
- Open up the machine is EC2 Instance, through
dotcloud ssh can not even go in operation. OS is Ubuntu Lucid. Lot of resources, RAM has 768 MB, / a 70G. But not the new open (a good start even go uptime is 89 days), I do not know is that the specifications are not fixed.
- ssh into the account is not root, not
sudo . Will ask the password, but did not know the password what pipe. ssh key is automatically generated into the.
- If the local directory itself is a git repository, then the code will pass the way up is to use git push.
- Implementation of the perl app included with ubuntu is not perl, but 5.12.3, on the / opt / perls, this is a perlbrew root. But the path is not perlbrew, should be installed automatically during the initial good.
- cpan dependency of the installation is installed to
~/perl5 to go, like the contents of this directory under the local::lib style. Should look the implementation of cpanm --installdeps --L ~/perl5 . this instruction.
- Direct support static file, not in the hands as Heroku in config.ru feet.
Now go test the App is lost and the number of MoreText (but this site does not refer to the past), is basically the process went smoothly, unlike the Heroku so few steps, but DotCloud greater flexibility to provide the beginning.
The current account registered DotCloud still need an invitation code, price list are not seen. But this really enough PaaS packed easy to use, the strength of the trend has swept the Perl community (though you need to install python to use (laughs)).
In short, are interested, you can with what they Twitter: @ dot_cloud with the blog . You can also fill out the Email Web site to notify you let them.
gugod's blog
30 April, 01:19, by gugod, machine translated from Chinese
Speaking about the time into the Perl module, not because they feel very satisfied with the existing, and was thus written a: Time:: Verbal
It currently features only difference between the two time points with the colloquial forms to display. ① The main features are very small units are discarded, and ② complete i18n / l10n support two.
For example, in Chinese:
> perl -MTime::Verbal -E ' my $tv = Time::Verbal->new(locale => "zh-TW"); say $tv->distance(time, time + 7**$_) for 1..10;'不到一分鐘一分鐘6 分鐘40 分鐘5 小時昨天9 天66 天一年多一年多
German:
> perl -MTime::Verbal -E ' my $tv = Time::Verbal->new(locale => "de"); say $tv->distance(time, time + 7**$_) for 1..10;' weniger als eine Minute eine Minute 6 Minuten 40 Minuten etwa 5 Stunden ein Tag 9 Tage 66 Tage mehr als ein Jahr mehr als ein Jahr
Hebrew:
> perl -MTime::Verbal -E ' my $tv = Time::Verbal->new(locale => "he"); say $tv->distance(time, time + 7**$_) for 1..10;' פחות מדקה אחת דקה אחת 6 דקות 40 דקות בערך 5 שעות יום אחד 9 ימים 66 ימים מעל שנה אחת מעל שנה אחת
Containing more than 60 languages. Content is translated from the rails-i18n plan. Can also customize the language translation.
Are at present to do the distance method is basically a Rails helper in distance_of_time_in_words , but not bad in this namespace can be supplemented with other parts of the succession.


gugod's blog
30 April, 01:19, by gugod, machine translated from Chinese
Speaking about the time into the Perl module, not because they feel very satisfied with the existing, and was thus written a: Time:: Verbal
It currently features only difference between the two time points with the colloquial forms to display. ① The main features are very small units are discarded, and ② complete i18n / l10n support two.
For example, in Chinese:
> perl -MTime::Verbal -E ' my $tv = Time::Verbal->new(locale => "zh-TW"); say $tv->distance(time, time + 7**$_) for 1..10;'不到一分鐘一分鐘6 分鐘40 分鐘5 小時昨天9 天66 天一年多一年多
German:
> perl -MTime::Verbal -E ' my $tv = Time::Verbal->new(locale => "de"); say $tv->distance(time, time + 7**$_) for 1..10;' weniger als eine Minute eine Minute 6 Minuten 40 Minuten etwa 5 Stunden ein Tag 9 Tage 66 Tage mehr als ein Jahr mehr als ein Jahr
Hebrew:
> perl -MTime::Verbal -E ' my $tv = Time::Verbal->new(locale => "he"); say $tv->distance(time, time + 7**$_) for 1..10;' פחות מדקה אחת דקה אחת 6 דקות 40 דקות בערך 5 שעות יום אחד 9 ימים 66 ימים מעל שנה אחת מעל שנה אחת
Containing more than 60 languages. Content is translated from the rails-i18n plan. Can also customize the language translation.
Are at present to do the distance method is basically a Rails helper in distance_of_time_in_words , but not bad in this namespace can be supplemented with other parts of the succession.
gugod's blog
29 April, 02:06, by gugod, machine translated from Chinese
For the time interval into a "3 minutes 29 seconds ago" The colloquial description of the module, there are four in the CPAN:
Time::Duration
Time::Elapsed
DateTime::Format::Duration
DateTime::Format::Human::Duration
Provided the first two inputs is a function of the number of seconds (for example 7240 such integers), the latter two is the DateTime::Duration object. If you do not have to meet rigorous results, and even some of the better fuzzy, then Time::Duration::duration of this function the best.
See the program and output compare https: / / gist.github.com/947706
DateTime::Format::Duration of the output format is to manually specify, so the comparison is not in the table.
Than an hour in the time interval, only the Time::Duration::duration function rounding second unit figures. But if you need to do I18N / L10N, but it is to win the other two mechanisms.


gugod's blog
29 April, 02:06, by gugod, machine translated from Chinese
For the time interval into a "3 minutes 29 seconds ago" The colloquial description of the module, there are four in the CPAN:
Time::Duration
Time::Elapsed
DateTime::Format::Duration
DateTime::Format::Human::Duration
Provided the first two inputs is a function of the number of seconds (for example 7240 such integers), the latter two is the DateTime::Duration object. If you do not have to meet rigorous results, and even some of the better fuzzy, then Time::Duration::duration of this function the best.
See the program and output compare https: / / gist.github.com/947706
DateTime::Format::Duration of the output format is to manually specify, so the comparison is not in the table.
Than an hour in the time interval, only the Time::Duration::duration function rounding second unit figures. But if you need to do I18N / L10N, but it is to win the other two mechanisms.
Cornelius
8 April, 09:33, by c9s, machine translated from Chinese
setter usually does not return the value, return the object itself using setter and then the other method and then call the object the way, is called cascading.
cascading of the most common example is jQuery, for example:
$ ('Div'). Css ({border: '1 px solid # ccc '}). Click (function () {}). FadeIn ();
Sometimes cascading take too long, the line was not any breaking, manual segmentation and indent again too annoying.
So wrote this plugin, cascading.vim
https: / / github.com/c9s/cascading.vim
Just finished a statement after the press
-- would automatically according to the statement in accordance with cascading filetype segment.
For example:
But probably only support the current filetype ruby, perl, php, part of the indent assumes users expandtab situations indent, not deal with other conditions. There needs to be combined.
As people said, patches are welcome.
Cornelius
5 January, 17:41, by c9s, machine translated from Chinese
is a new technology if the value of people can feel a sense of the naked eye to commercial interests will not necessarily be improved. For example, Python or Perl web site do not work, no matter what the new framework would not affect whether the customer wishes to purchase the product. However, the developer adhere to the "XXX is benevolent to develop" just the behavior of developers love their characterization of Bale.
http://twitter.com/ #! / c9s/status/1569948132446208
gugod's blog
29 December, 23:28, by gugod, machine translated from Chinese
shell function, stuffed .bashrc or .zshrc before use. Used pbcopy content automatically cut to the clipboard (Mac limit). System, no such instruction can remove the case.
pw () { p=`perl -e 'print map { chr rand(94) + 33 } 1..16';` echo -n $p | pbcopy echo $p }
This program generates the image I:tx)C<!:'xn((AY such a strong password, useful to the uppercase and lowercase letters, numbers, symbols. If you do not want such a strong set of figures that can be adjusted 94,33 . for example, notes 10,48, it will produce only阿拉伯数字weak passwords. If the length of 16 characters do not have to, it will be 1..16 part into 1..12 or 1 .. 8, and the like .
If you do not automatically cut to the clipboard before the function, in fact, can change alias (note that more than one -l , to appropriate output line):
alias pw="perl -le 'print map { chr rand(94) + 33 } 1..16';"
Or make a separate program executable file.
This code, or the weight back down each time to play.
Happy New Year.


Cornelius
29 December, 18:06, by c9s, machine translated from Chinese
There is a very old before Perl Planet Taiwan (PerlTW Planet) on this
http://planet.perl.org.tw/ , is maintained by the Wolong primary three, but it seems fallen into disrepair.
Shelling has acquired perl.tw domain name, so I re-host the PerlTW Planet, now on this:
gugod's blog
7 December, 08:45, by gugod, machine translated from Chinese
Duckduckgo is the author of a recent major search engine in use. There are several pleasing features:
- Keyboard interface - j, k, Enter, Cmd-Enter
- Special Q & A - ip, pw, yes or no
- He stood search -! Cpan perlbrew,! Ruby Number,! Yt Emacs
- Security - can be used throughout the https
- Anonymous - do not log the user's search history calendar
Full-text search results sometimes it does not feel as good as Google, can not adjust the time to do real-time search and so on. However, the keyboard can be used quickly before and after the visit (j up, k down) fifty, a hundred pen results, to want to see the first open in the background of the page (Cmd-Enter), or open in the current sub- Page (Enter), it became a very powerful and fast search tool for assistance.
If the search word in the knowledge base of several well-known (such as Wikipedia , CrunchBase , Wolfram Alpha ) of the known items, then DuckDuckGo presented the highest priority, and then the full-text search results. Most particularly, it has a special mark "Official site" (official website) function. If a keyword corresponding to the official website for direct, directly appear in the first. DuckDuckGo Goodies page illustrates a number of other available special keyword statement.
DuckDuckGo creators identified people (and programmers) are Gabriel Weinberg , also a CPAN Author: yegg . In his personal website, small detail illustrates DuckDuckGo server architecture , or even respond to a lot of other people's questions. Generally Perl / FastCGI / nginx / PostgresQL such a combination. (Know it is not, "came a Ruby On Rails" Web site after the general feeling particularly enjoyable.)
Most search services are discussed in the past in discussing the order of search results, rankings, scores, or advertising, etc., but DuckDuckGo convenient design in the interface can not help but back, again with a different point of view to think again "Browse search results "the problem. bing has also been demonstrated at the Apple WWDC on the use of the HTML5 to improve the use of the new design, although not seen as a real on-line design, but I was very happy to see. Google has also recently often a variety of revision. DuckDuckGo comparison is more like the design of "Hacker Friendly" feeling, just a little way to learn about those keyboard, you can use a very efficient way to fast operation, but, it is not difficult to learn.
Security and anonymity are the kind of "lost will feel important" things. Google Search has been relatively personal search history will remember, so if there can be more personal, more "satisfactory" ranking of search results, but always is linked to heart: I have so much information you record , What are they going to do will be used? On the other hand the more "personal" search results is not really very good, sometimes difficult to discuss. After all, good or bad search results when, in fact, more than imagined, in which subjective factors. In fact, PageRank is still a very simple calculation.
So far DuckDuckGo are free and no advertising of services, very nice. Not sure they have this service without any profit, but I hope the good service will continue.


gugod's blog
19 November, 17:49, by gugod, machine translated from Chinese
MT5 with for a while that one of the "Sites" design is really superfluous, really looking for a time to replace the MT4. Today finally hands, modified by the community converted OpenMelody . System and the installation process is basically the same with MT4, and a few file names have been changed, nothing difficult.
Part of the article is the first export in the old station to do, and then import the new system to do. Format is completely interlinked nature.
In addition to a large sign in the glare of the screen is purple, the little place is not pleasing to the eye.


Cornelius
15 November, 17:46, by c9s, machine translated from Chinese
typewith.me writing is a common platform. Moose today try to start translating documents, through the platform to translate, I feel pretty good.
http://typewith.me/bWn2dejlEo
Moose page document, has not yet turned finished, welcome to help translate, review.
Also in the translation into the way over there to see the Japanese translation of documents on the Moose resources, volume and speed of translation is quite terror ah, curious people can
http://perldoc.perlassociation.org/pod/Moose -Doc-JA/index.html here to see the Index.
Perl is magic in Japan there is a fairly large Ecosystem, even in the Tokyo office of the YAPC is almost the size of the world's largest. YAPC:: ASIA participants this year, more than 600 people, a total of three track, just Lightning talk for two days to arrange to spend at least half an hour to watch the wonderful Lightning talk. Taiwan to refuel ah
gugod's blog
15 November, 03:27, by gugod, machine translated from Chinese

Authored by the chromatic the " Modern Perl "book has been published, and also provides free PDF downloads, hope to share lots of circulation. ( → download page )
At the same time this book will be released to the iPad ePub used with the Kindle and Mobi formats. Even more interesting, the book's source code is also publicly Github: @chromatic/modern_perl_book .
Please note that this book and its source of authority for the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. , that is distributed free to share the PDF, but can not modify the text, it can not have business practices.


Cornelius
17 September, 20:07, by c9s, machine translated from Chinese
now, it seems like not very good and lightweight components available. orz
So write a Lightweight's
L10N class for this. be regarded as a Gettext the Wrapper class.
JavaScript can also try to learn both cascading into PHP inside, hope that this API design allows developers very happy.
Cornelius
16 September, 10:27, by c9s, machine translated from Chinese
Comment back here, posted this:
http://lightyror.thegiive.net/2006/09/rubypythonperl.html
Although the three languages have written some, but I'm more familiar with Perl programming language, Perl programming language I 』『 clarify the following ... XD
If the reading of the code module on CPAN, you will find out that Perl code is not write-only, but will become a write-only small, mostly to address the problem of low reproducibility, together with you especially like to take this part of the for discussion, and Perl has long left everyone down to the bias Bale. (Of course there are many, but not in this to mention)
Most of Perl programmers do not write write-only programs, but we all like to obfuscated the perl code that is out to show off, which is why the origin of one of the write-only.
However, if the other hand, who did not write write-only the code? In fact, everyone has written the code write-only experience, does not have to Perl for the job, right? :-P
In addition, the development of a long history of Perl, Perl has a proud unit test system, it is important to fully tested modules will be installed on your system, so even if a write-only do not have to worry about whether because of write- only cause other extension problems.
Incidentally, one question in recent years, the development of Perl, there are many modules have made the development of early modern Perl and Perl and has been a big difference. However, because most people's understanding for Perl is not much, so for Perl, we are still stuck in writing CGI 』『 that era. For example, Moose, Autobox module development, Perl can be made into post-modern object-oriented systems, allowing Perl to use more simple, powerful and easily extensible object-oriented features. The AnyEvent, Plack and other Perl modules also makes the development of the Web to develop more powerful and faster.
Relevant information about this can refer to gugod the good evils in perl (http://www.slideshare.net/gugod/good-evils-in-perl)
And the Moose: http://www.iinteractive.com/moose/
Plack:
http://plackperl.org/
Above. :-)
Cornelius
1 September, 08:44, by c9s, machine translated from Chinese
cpansearch is a CPAN module search tools to write C formed. Provide a simple and fast way to search the module to function, and the ncurses to build a choice to install the interface module (class aptitude), can one choose to install a module to install. No other settings using cpansearch CPAN or CPANPLUS can be used directly.
cpans Usage Description:
$ Cpans-f
Initialization source list
$ Cpans-u
Updated source list
$ Cpans Any
Search Any words
$ Cpans-i any
Ignore case.
$ Cpans-v Any
Verbose output (output version, and module path)
$ Cpans-vv Any
Very verbose. (Output version and the full module path)
$ Cpans - nc Moose
Start NCurses UI.
Develop
Development are now carried out in Github, welcomed the patches and the idea.
Cornelius
13 August, 15:26, by c9s, machine translated from Chinese
, unable to bear cpan and cpanplus search speed (each index reload + update over at least more than 5 seconds), so find time to write with a cpan module C search tools. 'Cpans':
http://github.com/c9s/cpansearch
After grasping down can directly make install. Depend on glib, and curl.
Speed difference really is 多阿阿阿阿阿 A!
gugod's blog
25 July, 06:53, by gugod, machine translated from Chinese
with Perl, Ruby, Javascript programming language was made of three Chinese name generator. Source lost to the gist on:
http://gist.github.com/476669 , false information to students accidentally useful. First and last name of the data are taken from chtsai [
1 ], [
2 ].


gugod's blog
25 July, 06:53, by gugod, machine translated from Chinese
with Perl, Ruby, Javascript programming language was made of three Chinese name generator. Source lost to the gist on:
http://gist.github.com/476669 , false information to students accidentally useful. First and last name of the data are taken from chtsai [
1 ], [
2 ].
gugod's blog
13 July, 03:22, by gugod, machine translated from Chinese
Blog in the Perl community to see this issue :
Consider a word (well, invented one): noogoo. Now, consider you want to do all possible combinations substituting oo with aa, that is, generate naagoo and noogaa.
In other words, write a function, let it eat three string input: s, x, y. And make it return a collection of content that is: there will be around s in substitution for the x-y combinations. A string substitution, there are permutations and combinations, is an interesting topic.
Thought of a recursive solution:
#!/usr/bin/env perl use 5.010; # Combinatory Substitution Generator # cs(s, x, y) #=> () # := s, if x is not in s # := cs(s', x, y) + map { sp + $_ } cs(sx, x, y), otherwise # where s' = s with the first occurence of x replaced with y # sp = substring of s from the beginning to the first character of first occurence of x # sx = s with sp removed sub cs { my ($s, $x, $y) = @_; return $s if index($s, $x) < 0; my $pivot_pos = index($s, $x) + 1; my $sp = substr($s, 0, $pivot_pos); my $sx = substr($s, $pivot_pos); substr($s, index($s, $x), length($x)) = $y; return cs($s, $x, $y), map { $sp . $_ } cs($sx, $x, $y); } say for cs("lady gaga", "ga", "gu");
Output such as:
lady gugu lady guga lady gagu lady gaga
Occasionally need a little exercise like this to prevent Alzheimer's ah ...


gugod's blog
13 July, 03:22, by gugod, machine translated from Chinese
Blog in the Perl community to see this issue :
Consider a word (well, invented one): noogoo. Now, consider you want to do all possible combinations substituting oo with aa, that is, generate naagoo and noogaa.
In other words, write a function, let it eat three string input: s, x, y. And make it return a collection of content that is: there will be around s in substitution for the x-y combinations. A string substitution, there are permutations and combinations, is an interesting topic.
Thought of a recursive solution:
#!/usr/bin/env perl use 5.010; # Combinatory Substitution Generator # cs(s, x, y) #=> () # := s, if x is not in s # := cs(s', x, y) + map { sp + $_ } cs(sx, x, y), otherwise # where s' = s with the first occurence of x replaced with y # sp = substring of s from the beginning to the first character of first occurence of x # sx = s with sp removed sub cs { my ($s, $x, $y) = @_; return $s if index($s, $x) < 0; my $pivot_pos = index($s, $x) + 1; my $sp = substr($s, 0, $pivot_pos); my $sx = substr($s, $pivot_pos); substr($s, index($s, $x), length($x)) = $y; return cs($s, $x, $y), map { $sp . $_ } cs($sx, $x, $y); } say for cs("lady gaga", "ga", "gu");
Output such as:
lady gugu lady guga lady gagu lady gaga
Occasionally need a little exercise like this to prevent Alzheimer's ah ...
gugod's blog
24 June, 14:00, by gugod, machine translated from Chinese
Perl 5.13.2, there is a change worth mentioning is the combined package block syntax.
use 5.13.2; package Hello { sub world { "hello world" } } say Hello->world; # => hello world
Grammatical structure like this is reminiscent of natural Java and Ruby's Class of. Or should be said that there are several object-oriented language ability, only about Perl syntax in the definition of special different namespace. In Perl 5.13.2 with other people after the same was. (Syntax like this seems to be some sort of industry-standard?) By the way, Perl's package not only the definition of Class only. Ruby to compare with the words, package is both a function of both Class and Module. For Perl programmers, the Class is used to define the package, is used to define Module package.
The feedback received from other modern languages, Perl syntax change also more every month a new development version is always released some amazing content. Perl's development is still more exciting was.


gugod's blog
24 June, 14:00, by gugod, machine translated from Chinese
Perl 5.13.2, there is a change worth mentioning is the combined package block syntax.
use 5.13.2; package Hello { sub world { "hello world" } } say Hello->world; # => hello world
Grammatical structure like this is reminiscent of the natural Java and Ruby's Class of. Or should be said that there are several object-oriented language ability, only about Perl syntax in the definition of special different namespace. In Perl 5.13.2 with other people after the same was. (Like this syntax seems to be some sort of industry-standard?) By the way, Perl's package is not only the definition of Class only. To compare with the words of Ruby, package is both a function of both Class and Module. For Perl programmers, the definition of Class is to package, to define Module also use package.
The feedback received from other modern languages, Perl syntax change is more, each month a new development version is always released some surprising contents. Perl's development is still more exciting had.
Weißes Rauschen
2 May, 14:33, by address-withheld@my.opera.com.invalid (Sascha), machine translated from Chinese
halfway
bàntú'érfèi
auf halbem Weg aufgeben ...
Weißes Rauschen
7 April, 19:50, by address-withheld@my.opera.com.invalid (Sascha), machine translated from Chinese
day and night
Méirìméiyè
kein Tag keine Nacht ...