Say Perl

Worldwide Perl Blogging

Totally
311 feeds,
9627 posts.

Uyutnenko

2 December, 03:12, by shootnix@yvision.kz (shootnix), machine translated from Russian

Hello.

I want to share with you, my dear friends, a new reference: shootnix.com . Long-held desire to write my little pieces of code that solve the problem more perlish, finally realized in the form Posterous -blozhika.

Some time ago I tried to write small posts in the style of «Perl so powerful ...", in which he proposed to solve the problem whichever way in Perl: time , two . We are pleased to have found this subject interesting not only for me.

Well, what then is continued in a more befitting place? Duc! =)

perl new features

26 November, 21:52, machine translated from Russian

Many times I have looked different slides about the new features of Perl Russian programmers. Seldom understood what they do. say relatively soon began to use, given - recently.

And then I stumbled upon http://perlhacks.com/2011/11/modern-core-perl-slides/ - I do not know why I had not seen before on slideshare, but understandably there is described and pro / /, and about the state and the rest.

That would be such a man wrote a book on the pearl ...

YAML

25 November, 01:54, machine translated from Russian

I did not expect this, but YAML:: Dumper and YAML are soooo sloooow. On the laptop with i7 gen2 (!!!) visibility delay of 1 + second one just use the module.

Well, there is a YAML:: Tiny.

Converting "firs»

24 November, 11:41, machine translated from Russian

Tried to convert text to UTF-8 would result in missing in KOI-8 punctuation to a form suitable for HTML:
 use HTML:: Entities;
...
my $ fixed = encode_entities ($ raw, "\ x {460} - \ x {2E2E}");
Worked strange dash was converted into — and quotes, Christmas trees - no. The reason was simple - the quotation marks in Unicode-firs are not there, where other punctuation with spaces - not in U +2000- U +205 F, and much closer - their codes U +00 AB and U +00 BB, that is, if we translate to decimal, 171 and 187. Sound familiar? :-)

Therefore, a more correct version is as follows:
 my $ fixed = encode_entities ($ raw, "\ x {A0} - \ x {40F} \ x {460} - \ x {2E2E}"); 

@ Freefd: * perl * mojolicious * success * story

24 November, 07:26, machine translated from Russian

recently wrote her first Web application Mojolicious. Only some 159 lines of code, including html template, do the same thing earlier and 577 in several modules. I loved it.

DateTime:: TimeZone: rake

22 November, 13:40, machine translated from Russian

I should not cancel after the transition to the winter fun of php-shnik. In the marketing module perl-DateTime:: TimeZone base hits though, and is generated on the basis of time-zones, but still his own. And, for example, in Debian stable for Moscow now is the time from UTC is converted incorrectly.

Recipes:
1. The most correct, perhaps, to update the module
2. For those with a batch repository - rebuild the package and deliver it.
3. Minimum, he's wrong - copy the appropriate description of the new version of the module.
4. Still, given that the supply module, judging by the comments, is a tool that parses and generates tzdata modules corresponding taymzonam, you can use them.

.

21 November, 06:14, machine translated from Russian

Over the past week:
- Exactly seven nights spent in trying to make a new version of my photo hosting
- Just 8:00 gone in to make the first working prototype dancerctl .

ps: git add. & & Git commit & & git push instead of svn commit - it's, well, excuse me. I would like on this occasion to pronounce the words that should not know the gentleman.

We look for Perl / C programmer udalenku. W / n to 120 tr in a month.

20 November, 23:52, machine translated from Russian

We look for Perl / C programmer udalenku with extensive experience in the development of frontend / backend heavy-sites.

Attendance million unique visitors per day to the server. Iron works at full capacity.

All the software is written in Perl + MySQL + third-party template. Need to constantly introduce new additions to improve performance, up to rewriting frontend / backend completely. Plus auxiliary software to write Perl.

Just need to configure the server (Free BSD) to the needs of the software. Those issues that will decide the admins, you can redirect them unnecessarily to the full server administration, hosting providers.

ZP on probation 2 months (in conjunction with the old computer programmer) - 45 tys.r ($ 1,500) / month. then 75t.r. ($ 2,500) / month. In the long term may be extended up to 120 tys.r ($ 4,000) for performance. On probation can pay for a week. Payment WebMoney WMZ or at one of the card payment systems.

Schedule a free, 7-8 hours a day. With good performance, maybe less. Other part-time work are not allowed on the side, unnecessarily just to think about our software.

Mandatory condition - a permanent presence in the ICQ and the ability to connect to the Internet no later than 1-2 hours after my call at any time, in case of an emergency, for example, did not rise after soft reboot the server.

You can contact me via PM, but it is better to ICQ 1 7 - 2 two - 0 4

Extension domain

20 November, 00:40, machine translated from Russian

ARGGHhh! I have already copied at least three times the extension of domain architecture, and even rewrote it so that it was correct in terms of architecture to find a simple mistake with the missing parameters in a function call ...

The current version of Padre some hellish nightmare with the clipboard. And terribly short of a custom avtopodstanovki.

And the saddest thing - for opensurs projects now really better to be on github-e. And so - I do not even know what to do Padre. There's sort of like you can even become committers, but this process will require reading the text in the heap they are even terrible wiki, writing letters to someone in general totally inhumane. I have a year like laziness. I'm in this totally not a fan of git-a, but the example of a Dancer-and studs around him very clearly that here for such a project - github - this is what you need.

Padre

17 November, 16:27, machine translated from Russian

Poyuzat Padre few days of the trunk. Fall sick, I put 0.92. But the trend is sad - the last really stable version was 0.86.

0.88 I dropped in the first three minutes of use - it may fall if the files were opened, podtseplennye via sshfs, which broke. Or it may not fall. Something tells me here that the normal testing the product at all. In previous versions of full stocks with sliding illuminated and non-working sometimes a quick search.

Grammar in Java, Perl 6 and Perl 5

14 November, 12:00, machine translated from Russian

Grammars are generally set the "rules" by which to determine the language constructs that support the same arbitrary nesting. Scope of the grammar - sophisticated parsing of text or data [1]. Grammars can not do without, in the case of compiler languages, interpreters, etc. Lately I've been using tight grammar in Java, Perl 6 and Perl 5. Shall explain briefly about them in each language. Grammar in Java JavaCC (Java Compiler Compiler), perhaps the most popular parser generator for Java. Includes utility JJTree to build syntax trees. Syntax for defining rules are simple: an element of grammar, a list of elements of grammar and an alternative list. For example, the following token defined by the numbers and the numbers: TOKEN: {<NUMBER: ( ) + ("." ( ) +)? > | <DIGIT: ["0" - "9"]>} Examples of grammars can be found in the repository of JavaCC grammars [2]. Grammar Perl 6 in Perl 6 grammars are part of the language and this is one of the most remarkable Fitch language. Therefore, there is nothing surprising in that the syntax of Perl 6 is described by his own grammars [3]. Perl 6 grammars in fact represented in the form of classes and can inherit other grammar. The processing of the text can be combined with the construction of a syntax tree. To this end, the parser is passed a parameter action, whose value is an object handles matching tokens (in Perl 6 they are tokens and token rule). For example: my $ res = Plosurin:: Grammar.parse ($ txt,: actions (Plosurin:: Actions.new)); handling of $ txt, in case of identical tokens, to construct an abstract syntax tree (AST) will be called the object's methods Plosurin:: Actions. The results of the call will be part of the result tree. This integration into a programming language to simplify the use of grammar. How much more? You can for example compare the grammar definition for processing JSON for JavaCC [4], and Perl 6 [5] (for clarity, in a gist [6]). Grammar in Perl 5 to Perl 5 grammars implemented as a module Regexp-Grammars [7]. The following example from the documentation of the module shows the rules for parsing LaTeX: use Regexp:: Grammars; $ parser = qr { <[Element]> * | \ \ ? ? \ [<[Option]> +% (,) \] \ {<[Element]> * \} [^] [\ $&%#_{}~^ \ S,] + [^] [\ $&%#_{}~^ \ S] +} xms; those who are familiar with Perl 6 grammars, the example above will look familiar. On the surface, and on opportunities Regexp-Grammars is very similar to Perl 6 grammars: inheritance is, the construction of a syntax tree. And in terms of functional debugging rules even better than Perl 6. Regexp:: Grammars one of those libraries, which are very useful to know! NOTES1. Parsing and tools. http://ru.wikipedia.org/wiki/Синтаксический analiz2. JavaCC grammar repository. http://java.net/projects/javacc/downloads/directory/contrib/grammars3. Perl 6 grammar. https://raw.github.com/perl6/std/master/STD.pm64. Grammar definition for JSON JavaCC.http: / / java.net/downloads/javacc/contrib/grammars/JSONParser.jjt5. Grammar JSON in Perl 6. https://raw.github.com/moritz/json/master/lib/JSON/Tiny/Grammar.pm6. Grammar processing JSON for JavaCC and Perl 6. https://gist.github.com/13635807. Library of grammatical analysis for Perl 5 Regexp-Grammars. http://search.cpan.org/dist/Regexp-Grammars/

@ Freefd: * web * development * mojolicious * browser * websockets

14 November, 07:28, machine translated from Russian

Total:
Chromium 14.0.835.202 Linux - vebsokety work out of the box and immediately.
Firefox 7.0.1 Linux - vebsokety work through and with a bunch of ass workaround.
Opera 11.52 Linux - vebsokety can be included in the settings, but they do not work.

And so would do almost "normal" means of transport ordinary DC on the web.

The solution of the problem of encoding numbers in Haskell and Perl

14 November, 06:03, by Eax, machine translated from Russian

Last week I once again took part in the competition for functional programming from _darkus_'a. In this article you will find the problem and its solution, as well as some of my observations regarding the OP. Thus, the formulation of the problem was as follows: Dan indicator consisting of n bulbs that can burn or not burn. Given an alphabet of k symbols, which [...]

GraphicsMagick

12 November, 11:05, machine translated from Russian

Ah. Of course, I'll put the GraphicsMagick and use it, but with the orientation of development is clearly something wrong.

Mercurial, on the Download page makes no reference to the source (I'm only 10 minutes later I saw that in the main menu there is a separate link to Source), download the Perl Graphics:: Magick, rather, that much more valuable to read its documentation on search.cpan.org - not. When installing packages from Graphics:: Magick is placed, but to put it in a separate ubuntu, which is not obvious, because the documentation on the site says that it is placed immediately with gm.

Well, that too sadly, the stable version of the year with a tail, is unstable, as amended, and new chips on 7 of my 22-inch screens, but it is clear that unstable there better not to put into production. In general, would be stable releases at least once in three months - it would be much better.

upd: there still is a wonderful documentation for Perl bindings ...

Perl-developer at freelance, work with the template

9 November, 16:41, machine translated from Russian

Goodnight! Urgently looking for perl-developers who are familiar and work with templating HTML:: Mason. It is possible to earn well.

Two major projects in our company are now in the final stage of development - two different themed social network. We decided to accelerate the launch parallel work and provide layout implementation of these projects in a single task and give it a new programmer (yes, we can take in the state, Moscow), or on freelancing.

You can work remotely from home, the office, from anywhere. The main thing - fast. We want both to run the project until the New Year. We - a company Ontika specializing in the development of complex and heavily-making, sites and projects.

If interested - send example perl-code, a template, resume and photo to oleg.bunin @ ontico.ru. Well, as the value of their work-week;)

Perl / [From sandbox] calms the nerves with Perl and GD

8 November, 08:42, by student_ivan, machine translated from Russian

Foreword


I am one of those people who are often exposed to stressful situations. You can get rid of stress in different ways. In this topic for I will show you how I do it.

Writing in Perl in a functional style

7 November, 06:00, by Eax, machine translated from Russian

Shortly after they met with Haskell, I've noticed that some problems can be solved easily painfully with the functional approach. It appeared quite natural (for me) issue. Is it possible to apply this approach in Perl? One possible solution that comes to mind is to write a shared library in Haskell and load it into a [...]

Abnormal programming / [From sandbox] Write a bilingual program

6 November, 18:48, by cyberpunkyc, machine translated from Russian

Recently, I faced a difficult little problem that I threw a friend. The bottom line is that by writing a source code, you can compile it with gcc and executed, and also through the interpreter to execute perl. It would seem, is not that difficult, but not all programmers will think how to write this source. Proceed to consider the original programs in C and Perl.

Sandbox / [From sandbox] Write a bilingual program

6 November, 18:48, by cyberpunkyc, machine translated from Russian

Recently, I faced a difficult little problem that I threw a friend. The bottom line is that by writing a source code, you can compile it with gcc and executed, and also through the interpreter to execute perl. It would seem, is not that difficult, but not all programmers will think how to write this source. Proceed to consider the original programs in C and Perl.

What hourly rate for perlovika is now considered a "great deal"?

5 November, 15:44, machine translated from Russian

In short, I was approached by an old client to help finish the project in Perl. I am too lazy to bother with this, I want to call defensive hourly rate, but that it is not doubted my sanity. How much are the average hourly wage ceiling for the super-duper-perl programmers? 70 bass per hour? 90? 40?

Untitled

3 November, 00:16, machine translated from Russian

Maybe someone faced with a similar?

There is a demon on the basis of XML:: Compile:: SOAP:: Daemon , to which are connected modules with global variables and all sorts of useful functions (including pulling data from the database).
To it requests are sent through the test client script.

When querying, where the appeal to the functions of most of the connected modules, if the function accesses the database, the client script reports an error 500. Judging by the debug records demon tries to execute a call neinitsializovannoy dbh-variable. With access rights to files at the same time everything is in order, a module with functions in the same folder as he sees and is normally in the function.
Race conditions, like, too, no problem occurs even if the query one.

If I call the same function of the module from the demon itself directly, not through the client, it works.
If I shoved the same code database query into a demon, without plug-ins, and everything works with a client, too.
If the database query functions not everything works, too.

What is at least theoretically could be wrong?

Module for converting wiki markup to html

31 October, 11:36, machine translated from Russian

Citizens associates, help pliz working module for converting wiki markup to html?
Something dao my search cpan exceedingly low (there are only modules for converting from the wiki in html or 6.3, the modules are not really working (the maximum that I have made this frame in html markup tags, marking itself remains unchanged)
I tried:
Text-Textile - lost tags at all == header ==
Text-Tiki and the Text:: MediawikiFormat simply frame the code in the pre not touching the wiki markup. This is because of the fact that literally tasted today.

As well, Ruby?

31 October, 11:03, by xoma, machine translated from Russian

I've always thought that such major projects as Python, Perl, Ruby, and others that are written by people "genius." And it turns out that they have all kinds of jumps is trash code. Came across an article today on this at rubiinsaydere http://www.rubyinside.com/ruby-1-9-3-faster-loading-times-require-4927.html. Are (as far as I understood) when using the «require», which connects the new file into the program, the name of [...]

29 October, 17:49, machine translated from Russian

Seeing the sunset, we live in expectation of rising,

Creating modules for Perl 6

27 October, 10:00, machine translated from Russian

In time for the Perl 5 modules is CPAN, the Perl 6 this archive no. The site CPAN6 [1] regarding the timing of a following sentence: "The first release of the CPAN6/Pause6 modules is planned for April 2010." The plans not only to host CPAN6 code for Perl 6, as well as libraries for all languages ​​[2], using VM Parrot. At the proposed logo shows schematically the people who hold hands, which symbolizes the unity of personal space. More information about the proposed architecture can be found at CPAN6.org. I should add that CPAN6.org - a project which may become an official CPAN6. However, there is some attempt to formalize the rules and the installation of modules for Perl 6 in the form of package manager Panda [3] (and earlier Proto https://github.com/masak/proto). Relevant requirements of a few simple modules are placed on the http://modules.perl6.org/. The basic steps for creating a module of Perl 6 module structure directory structure similar to that of the usual module for CPAN. plosurin ├ ─ ─ bin │ └ ─ ─ plosurin ├ ─ ─ lib │ └ ─ ─ Plosurin.pm ├ ─ ─ t │ ├ ─ ─ t01.t │ └ ─ ─ t02.t ├ ─ ─ Changes ├ ─ ─ LICENSE ├ ─ ─ META.info └ ─ ─ README for those who are accustomed to use the Makefile, there is a small script masak / ufo. Once launched, it will create a template in the current directory Makefile. Become available, the command make test, make install, etc. META.info contains information about the module I just bring the contents of this file for my module: {"name": "Plosurin", "version": "0.02", "description": "Perl 6 implementation of Closure Templates", "depends" : [], "repo-type": "git", "repo-url": "git: / / github.com / zag / plosurin.git"} Field names speak for themselves. Place the module on github. Is recommended. But I think that the repo-url file META.info can specify different from the github repository, for example, gitorious. Add a link to your project in a list of projects is in the file: https://github.com/perl6/ecosystem/blob/master/META.list How do I add the address of the repository? So: fork-> clone-> edit-> commit-> push-> PullRequest. If the project is hosted on another service (for example, referred to gitosis), let me address your repository, I'll add it directly to the perl6/ecosystem. Modules.perl6.org - CPAN6 couple of years ago, all working modules for Perl 6, it was easy to remember [4], but even today they are still very small. All of them are posted on the http://modules.perl6.org/, which is an excellent source of working examples of code in Perl 6. For anyone interested in Perl 6, I advise to look at the most popular page at the moment of modules [5]. Perhaps you will find a reason to try Perl 6! NOTES1. The project to create CPAN6. http://cpan6.org2. Implementation of programming languages ​​in a virtual machine Parrot. Parrot-Based Implementations of Programming Languages3. Package manager for Perl 6. https://github.com/tadzik/panda/4. Article devel/p6-perl6-toys. devel/p6-perl6-toys5. Perl 6 Most-Wanted-Modules. https://github.com/perl6/ecosystem/wiki/Most-Wanted-Modules

Installing Padre from CPAN

27 October, 07:05, by Foxcool, machine translated from Russian

For a long time could not install the latest version of Padre from CPAN, as to install the module dependencies needed Alien-wxWidgets and it all "valilos." I was searching for the same package of fresh and set and did not help. But recently went on Fedora Update Perl and core modules, which are repositories of packages. Renewed, delivered, put the Padre on CPAN fresh - works! I will be father in law. It is said that he does not fall after every sneeze. (: $ Sudo yum install mingw32-wxWidgets perl-Alien-wxWidgets gtk + $ sudo cpanm Padre generally already have 0.92, not 0.90, but the latest on CPAN yet somehow did not spread.

Portabl version.

26 October, 15:08, machine translated from Russian

I want to try a version with portabl version of the Pearl for Linux / GNU i386.
That is, there is a folder where you installed the program with all the junk, and all needed her pearl-ins are not used in the system, and from this location ...
And the list of modules Tk, Image:: Magick ...
Can I somehow do this? Just as I understand it for different systems (Gentoo, Debian, RedHat, ...) these modules compiled dolozhny?

YAPP # 11: World News Perl for September

26 October, 10:17, by xoma, machine translated from Russian


Saint Perl - 3

25 October, 09:15, by ash, machine translated from Russian

December 18, the 24th birthday of Pearl, the third time will be Russian Pearl Workshop Saint Perl .

Participation is free. Registration is open (you can login with their password from the previous events).

We invite speakers, exhibitors and sponsors! business incubator " Ingria "for the provision of facilities.

Saint Perl - the 26th event in a series of YAPC:: Russia , founded in 2007 and covering the territory of seven countries: Rosiii, Ukraine, Belarus, Kazakhstan, Uzbekistan, Bulgaria and Latvia.

Yet Another Perl Podcast - Issue 11

25 October, 08:27, machine translated from Russian

I hope nobody will mind if I'm a bit new release here propiaryu YAPP?



Articles:

  1. Perl script for sending SMS
  2. Why Perl? (Translated into Russian)
  3. How do I change Perl syntax to your taste
  4. Back from BlackPerl 2011
  5. vti about "small gifts" and a very interesting project (in perl, esessno) privytalks.com
  6. Performance packages in Perl OOP
  7. (Question) Perl, and database testing
  8. Mojolicious And Dancer
  9. Larry Wall's birthday:)


Jobs:

  1. Login to hh.ru and find on-demand "Perl"
  2. (!) MAIL.RU - PERL programmer (cool Perl - about - bison)


Interesting CPAN modules:

  1. AI:: ParticleSwarmOptimization - cm http://goo.gl/JvRQM
  2. Google:: Plus
  3. Set:: Functional



Offtopic:

  1. Of information . Chic series of articles about compression algorithms already in 6 parts.
  2. Try to cluster file system GridFS (the one that at MongoDB) + benchmark
  3. In bitbaket now has Git



[ Rpod | RSS | Twitter ]

Perl / [PODCAST] Yet Another Perl Podcast - Issue 11

25 October, 08:15, by afiskon, machine translated from Russian

Private methods in Perl

24 October, 14:35, machine translated from Russian

http://www.slideshare.net/koorchik/maybe-you-do-not-know-that

Frame 34 - real private methods

 my $ name = sub {
    my $ self = shift;
    ...
}

$ Self-> $ name ();
$ Self-> $ name ('viktor'); 

ps: good, but service - slideshare. One only frustrating - to find something really interesting - have to scroll through dozens of presentations. And there is copy-paste does not work - you have to download the presentation locally, open to something local and only then. It was very uncomfortable.

Perl Weekly

24 October, 13:35, machine translated from Russian

may not all one has to do with Perl, know that some time ago, there is another news site .
Perl Weekly newsletter this week, collected manually Gabor Szabo (Gabor Szabo) and delivered to you absolutely free of charge via email or RSS. This is an overview of recent releases, reminders of Perl-events, hot discussions and interesting posts about Perl in your inbox every Monday.
Simply subscribe to the newsletter at http://perlweekly.com , very convenient.

Perl 5.16 and that we have of him did not know

23 October, 13:49, by xoma, machine translated from Russian


Perl 5.16 and that we have of him did not know

22 October, 21:45, by ash, machine translated from Russian

Anatoly Sharifulin translation prepared presentation Jesse Vincent Perl 5.16 and Beyond , which he visited on several recent YAPC.

Programming / Programming Language

22 October, 08:49, by valualit, machine translated from Russian

questions of all time: "What programming language to learn? What more you want? ".
Since the issue date and I have about it a little pent, I wanted him to reveal himself as passed this way and in his time tormenting question quite a few people.

In principle, I will not compare languages ​​at work, because the comparison must take into account many factors, and compare a banana and a carrot, all agree - is wrong.

The issue will open on the basis of their life's journey together with the findings and personal considerations.

The Way I went to the programmer with PHP, I have a choice at that time did not exist, but in retrospect I have no regrets. Of course I already knew HTML, CSS and some JavaScript. After several years of working with the task of creating PHP websites are no longer allowed the euphoria and passionate as any in this business wanted something more. At that time, more for me was to create software programs. All languages ​​are very complicated and the first thing I tried to find out how to write programs using Visual PHP - you guessed it, and was preceded by a study of new languages.

Once I was a similar question, once decided to switch to Linux, I had only one friend, mentor, whom I got to the question of whether it is better to put on debian - gnome or kde. He gave me great advice. Advised me to put all possible desktop environments - to try and decide what is right for me and clearly explained, there is no need to compare what an individual, not better or worse.

Lazy comparisons of unlike images

20 October, 15:36, machine translated from Russian

Someone vzglyuchil: either reader (card badly stuck?), Or a camera, then eh penguin in a laptop is naughty - a bunch of pictures no longer legible. He sat down at vindovuyu car, found there an ancient VaioSoft Recovery Manager - regained almost all (and as such under Linux?), But only with non-native names. What should I do? As compared with what normally written off?

It helped that in Nikon (about the other cameras will not tell) is the count of photos, that ticks from the output device. Rename files in the current directory to the form №. Jpg so you can:
exiftool '-filename<${shuttercount}.%e' .
Almost all of the renamed, there were only damaged files (about half a percent of total). Renamed everything to get in touch and well files, and recovery - to a single numbering. Compare it became much easier :-)

Requires perl and Image:: ExifTool . Under Windows is not taken off (although all that is necessary and it was) - well.

Conducted an experiment - trailer unit, launched cheaters script - works as expected. We will check the card reader ...

About my past errors and bygone perfectionism

20 October, 06:03, by Eax, machine translated from Russian

Over time, views on some things change. Six years ago I wrote in C + + (and actually - in pure Cu) using the Windows API and for me it was "our everything". Yes, I was already a rare nerd:) And then I tried Perl and all this fuss with pointers and manual memory management has become [...]

As I once tupil two days out of the blue

18 October, 09:17, by bappoy, machine translated from Russian

On the eve of the first anniversary of last autumn DST in Russia recalled a fakap three years ago (early 2008). I then engaged in repairing the attendance statistics on a regional Login or register, which I supported as a friend.

They had two servers, one on the internet show content to visitors, and the second was located in the office and kept the interface to administer our website. All farm work under FreeBSD 6.1 on very old machines, on the main server was a Pentium 3 and 384 MB of RAM (however many years ago about such a configuration, one could only dream ). Apache 2.2.2 kept a log of visits in the mode of «combined», and at night they all accumulated in the last day was treated full-applets logresolve (converts IP-addresses of visitors to host names) and copied to a separate file resolved.log. Then pick up an office server resulting file over HTTP (for security reasons all the "alternative" methods of file sharing have decided not to use) and parses it awstats'om. Such is the ingenuous shemki. But it worked for exactly two months until mid-December 2006 and ceased.

Apart from a few bugs found a couple of strategic failure. First, the office server sometimes disconnected due to problems with electricity, and the log is not taken in time, and the next day just to be supplemented by, and after two or three days off with logs file has grown to such proportions that even in a compressed form for too long passed would be to http, and taking away the script will simply fall off the timeout. Second, there is established logresolve naturally spoiled logs: read lines from the first 1024 bytes, handles IP-address, and published them in STDOUT, completing the transfer line, and then read the following 1024 bytes, etc. As a result, the rows that contain, for example, long referrerskie URL, were broken into several lines of 1024 bytes each, which may not matter to awstats, but it is extremely difficult to additional processing of the log.

As a result, from December 2006 to the log file grew in size up to six gigabytes. I decided it was best to break it for months and months to feed these parser turns, but first had to deal with the extra line breaks. We quickly sketched on the one-liner sed, which removes extra line breaks, if not in the third field contains the date.

However, despite the fact that both small and large enough to present excerpts resolved.log skriptik working out the relatively normal, the log of real read only the first 170 megabytes of coppers and the script hangs for a long time. I decided that maybe something did not realize because of the small experience of this kind of writing scripts for sed, and rewrote the same algorithm in perl and c - to no avail: after reading the first 170 megabytes, nothing happened.

 my $ b ='';
while (<>){
        chomp;
        if (/ \ [[0-9] + \ / [a-zA-Z] + \ / [0-9:] + \ \ +0300 \] /) {
                print "$ b \ n";
                $ B = $ _;
        } Else {
                $ B. = $ _
        }
}
print "$ b \ n";

Several times I drove the scripts through valgrind with maximum leakage checks, get rid of some of the mistakes in the end read a lot of documentation on freebsd on possible restrictions on the size of the process in memory (although more than eight kilobytes of program memory is not occupied), etc. . In general, for two days, dropped out of life, spending time in debugging ...

Finally found the cause of my anguish: the regular expression defining feature of the recording log, was hard-coded time zone 0300, while the transition to summer time it changed in 0400. Therefore, when the cycle reached in March 2007, several hundred thousand lines until next October just skipped, and because the server was slow, then Ctrl + C and kill-TERM scripts to react immediately, and to create a sense of hovering.

Once I corrected this regexps, everything went like clockwork: fed awstats'u old logs, tied logrotate, taught scripts to collect statistics over scp; parallel crown set anacron , so that the fence and log analysis was performed on a daily basis regardless of whether or not the "office" server in 4 hours and 15 minutes in the morning. And then did criminal

How do I change the syntax of Perl on your taste

18 October, 06:05, by Eax, machine translated from Russian

There is a module for CPAN'e called Modern:: Perl. Currently, it is equivalent to writing a connection string «use strict» and «use warnings», but also leads to the activation of several other useful features pearl. I was wondering whether it is possible to go further and write a module loaded, for example, Try:: Tiny and Moose? It turned out that to write such a module is quite simple. Here are [...]

event-driven perl

17 October, 22:13, machine translated from Russian

For example, we want to make a web server for delivery message to the browser by the server protocol
Server Side Events (supported by the latest browsers Opera, Chrome and Firefox).
For a perl framework for dealing with events AnyEvent . There is also an interface to the library
Spread to exchange (and queue) messages between processes (including on different machines).

It is obvious that they are destined to be together:)

Let's see how.

#! / Usr / bin / perl-w
use EV;
use AnyEvent;
use Spread;
use YAML;
use Twiggy:: Server;
use open IO => ': encoding (utf8)';
use strict;

$ | = 1;
sub LOG {
   print STDERR join ('', map {ref ($_)? Dump ($ _): $ _} map {defined $ _? $ _: '_'} @ _), "\ n";
};

my ($ mbox, $ group) = Spread:: connect ({spread_name => '4803 ', private_name =>' psgi '});
die Spread:: error () unless defined $ mbox;

Spread:: join ($ mbox, $ _) for qw (dial connect hangup);


Here is the connection to the server Spread (default daemon is started
listening to localhost on port 4803), private_name a unique identifier
the process. Two processes with the same identifier can not be connected simultaneously.

To receive messages must be signed by one or more groups of messages (the group - just
text-string identifier that is used when sending messages to the message server).

my% conn;
my $ w01 = AE:: io $ mbox, 0, sub {
   my ($ service_type, $ sender, $ groups, $ mess_type, $ endian, $ message) = Spread:: receive ($ mbox);
   foreach my $ k (keys% conn) {
      $ Conn {$ k} -> {writer} -> write ('data:'. $ Message. "\ N \ n");
   }
};


In fact $ mbox, returned Spread, is the ordinary filehandle, in particular, socket. So
for this socket can be monitored by AnyEvent io watcher. When will Spread the message
then execute the code kallbaka who receives the message and send it further joined browsers.

LOG ('startup');
Twiggy:: Server-> new (host => '0 .0.0.0 ', port => '5001') -> register_service (sub {
   my $ env = shift;
   return sub {
      my $ respond = shift;
      my $ writer = $ respond-> ([200, ['Content-Type', 'text / event-stream']]);
      my $ fh = fileno ($ env-> {'psgix.io'});
      $ Writer-> {handle} -> on_error (sub {
         LOG ('Connection close', $ fh);
         delete $ conn {$ fh};
      });
      LOG ('adding conn to pool', $ fh, $ env-> {HTTP_USER_AGENT});
      $ Conn {$ fh} = {env => $ env, writer => $ writer};
   };
});

EV:: loop;


As a Web server is used psgi-compatible event-driven pure-perl server Twiggy ,
interface supports psgi.streaming.

psgi.streaming is that the application returns a reference to the code instead of
list [code, headers, response]. This code when you call is passed a reference $ respond,
through which you can get a wrap on the client socket $ writer, then
it is already possible to write to the socket all that pleased.

writer encloses AnyEvent:: Handle handle, which can be detected
processing events of the form on_read, on_error. Here, according to on_error socket is removed
from the pool and no longer receive messages.

It should be noted that the destruction of $ writer (for example, when out of sight
block) client socket will automatically close (writer holds another AnyEvent watcher
just for this), so in order to connect to brazuerom had all the time
writer remains open to the pool% conn.

Next, svezhenapisanny server messages can interbreed with existing Web servers,
For example forkayuschimisya as starman, through reverse-proxy nginx, like so:

nginx.conf:
server {
  ...
  location / event {
    proxy_pass http://127.0.0.1:5001;
    proxy_buffering off;
  }

  location / {
    proxy_pass http://127.0.0.1:5000;
  }
}


proxy_buffering need to nginx could not be tried and gave answers zakeshirvat as it is (otherwise messages will be sent and a bunch of late).

and L mysq persistent connections

14 October, 13:41, machine translated from Russian

There has recently been discussed, but the post was removed, and there were interesting commentary that I have not had time to keep, so he decided to raise the issue again.

perl, Dancer, like when you start the application instances skonnektitsya with musklem and further, if possible, use this connection and not make a connection before {} and disconnection in after {}. Here is a descent pridumyvetsya:

 $ Dbh = DBI-> connect ("DBI: mysql: dbname =". $ Dbname. "; Host =". $ Dbhost, $ dbuser, $ dbpass, { 
             PrintError => 0, 
                AutoCommit => 1, 
                mysql_enable_utf8 => 1,
          mysql_auto_reconnect => 1,
        }) 
or return undef; 

At first glance, it works. Should I consider something else?

From a cursory reading of the sources I do not understand how to do this thing inside - if done in front of each request -> ping or try to run the query and, in the case of a reply containing a "gone away" is the second request and reconnect? If you do -> ping () - it should be very slow - better to make your wrapper, or is there something good and ready?

Separately - what is a good alternative to DBIx:: Connector, if the script can forkatsya, run under mod_perlom or something else? In DBIx:: Connector documentation such monstrous structures that ipolzovat it is not desirable.

Perl / [From sandbox] Light PERL-script to send and receive SMS via mobile phone

14 October, 10:49, by sevic72, machine translated from Russian

Preamble



In the process of self-development of the "Smart House" (hereinafter referred to as DM) occurred periodically need to write a small, but very necessary tools, programs, scripts, in one form or another already written and available on the Internet, but for one reason or another unsuitable for use in the project. "Why are not suitable?" Ask an experienced developer, can I just "do not like cats because they do not know how to cook them?".

DIY or Do it yourself / [From sandbox] Light PERL-script to send and receive SMS via mobile phone

14 October, 10:49, by sevic72, machine translated from Russian

Preamble



In the process of self-development of the "Smart House" (hereinafter referred to as DM) occurred periodically need to write a small, but very necessary tools, programs, scripts, in one form or another already written and available on the Internet, but for one reason or another unsuitable for use in the project. "Why are not suitable?" Ask an experienced developer, can I just "do not like cats because they do not know how to cook them?".

Building PSGI-compatible Web-framework'ov

13 October, 13:10, by xoma, machine translated from Russian


I do not understand.

12 October, 20:44, machine translated from Russian

Why when writing than good Perl, or where and how Perl is used, be sure to come in the comments someone with stories about what Perl "dead"?

Meanwhile, Google tells us that:

Perl dead: About 8,670,000 results
Python dead: About 20,300,000 results
Java dead: About 91,100,000 results
Erlang dead: About 330,000 results
Haskell dead: About 2,610,000 results
Ruby dead: About 42,000,000 results
Javascript dead: About 160,000,000 results

I think you can only rejoice for javascript and erlang. Though javascript is just language which is not "dead" for a long time, and it is not in the properties of language, and in many browsers.

Iron / "smart house" with his own hands. Part 4. Organize Web-based interface

12 October, 10:15, by Neuronix, machine translated from Russian

In the last article, we have been able to teach our system of "smart home" to recognize what we say and synthesize voice answers with Google.
Today I want to tell you how to organize access to our system through a web interface.

What is palyatsya sites added to the SAPE

11 October, 06:00, by Eax, machine translated from Russian

Some time ago I was a curious puzzles. We had to write a script that defines the domain name, are sold on the site links and exchanges such as SAPE TrustLink or not sold. *** You can solve this problem in different ways. For example, in serche once slipped opinion that search engines analyze IP and Whois data sites. If [...]

Software / Armenian - Russian dictionary is now online

8 October, 10:54, by temujin, machine translated from Russian

Last year I wrote that the largest Armenian-Russian dictionary published in the Soviet Union and laid out in digitized format for use in a dict or StarDict GoldenDict.
We're doing in their spare time, so changes do happen, but not that often.
During this time, there were 4 "release" six months ago, released version 1.20. Were fixed hundreds of bugs in the sorting, spelling, just a typo. Many bugs have been found in the print edition, and they too have been corrected in the digital version. Members have made a version for the program based on Lingvo dict files.
And finally the most important change has recently been placed in the APC online and can be transferred directly from the site.

One-liner to extract a domain belonging to the same links from HTML or plain text

7 October, 17:56, machine translated from Russian

perl -nle ' print $1 while m!(http://example.com/[^" >]+)!g'
For incoming data
<a href="http://example.com/one"> one </ a> and <a href="http://example.com/two"> two </ a>
http://example.com/first and http://example.com/second
none
returns
http://example.com/one
http://example.com/two
http://example.com/first
http://example.com/second
In plain pearl script - for githabe .