Nice, WTFish riddle for You today. Imagine this – there is a XAMPP server – Windows, apache, Perl and PHP (from www.apachefriends.org) installed on your laptop.
I hope the previous sentence did not put you off, linux fans 😉
Still with me? Read on: you have a typical hello world type perl script, serving as an example and test, that is delivered with that whole bunch.
It works. Shows “OK” via CGI.
You write your own small script – get server error 500 – “End of script output before headers“.
You put your script in the same directory as that example – still get 500.
You copy your example script to other file in the same directory and edit it – 500.
You copy your example script to other file in the same directory and NOT edit it this time – 500.
You edit your example script (that original file) , do the slightest change – for example change string to “OK2” – 500.
You edit your example script back to be exactly as it was before – it works.
Good text editor was used – Notepad++ (saving as UTF8 without BOM, line endings were not messed with), so it was not the cause of problems.
Guess where the problem was.
You can think for yourself, the answer to the riddle, cause and solution is below (scroll if you have no idea)
The antivirus/firewall program, COMODO Internet Security was causing the problem. It did not allow to run neither new perl files, nor modified existing perl files. I guess it somehow accepted the original file that was created during XAMPP installation, but when someone tried to modify it or make new one – it won’t run.
Solution – temporarily turn off sandbox feature or the whole COMODO antivirus/firewall at all. Or change it to other product.
Did someone forgot about perl ironman competition and neglects it?
I received feedback from conference attendees about my presentation at YAPC::EU. And it was very good 🙂
After the conference attendees are encouraged to express their opinions on presentations they attended and grade them. Then the aggregated grades and opinions are sent to speaker.
I was a bit nervous, but fortunately presentation about WTFish side of using Perl was graded between 7 and 10 (on a scale from 1 to 10), mostly 8-9.
There were also opinions – good and bad.
Bad: I could have been speaking louder and with better intonation and gestures. Slides also could be a bit better. Someone even wrote “Poor guy, it is hard to present in another language. I hope he isnt disheartened, his presentation is good” 🙂
Good opinions (quoted from the feedback I got):
- Covered well some common but not obvious traps in Perl for newbies. The material was good.
- Good title and subject – humourous way to present this sid of Perl. As a total beginner some parts I knew of and felt the same WTFness and it is nice to feel that it is as mad as I thought!
- This presentation pin pointed some of the things that regularly “bite” newbies, so it was most valuable. It had many examples, and I hope I can remember them all. [ note: there are slides available to download at this blog, so you don’t have to remeber all 🙂 – Lech ]
Thanks for good opinions 🙂 and also for bad – those taught me something about presentations. Next time it will be better 🙂
Well, the perl 5.10.1 was released some time ago. It includes some nice features and some strange features.
I’m osting it in “future” category, as I do not intend to use it now. Neither 5.10. Why? It is being changed, and I like language I develop in to be more constant 🙂
- bug-fixes, optimisations, tuning. Runs faster.
- autodie pragma 🙂
- “..” operator is interpretedin boolean context when used inside a when statement – yet another WTF. So, the behaviour of “..” is not less consistent. On the other hand it may be usefull.
- Change of smart match behavior in comaprison to 5.10
- better encapsulation
- ordering matters – $key ~~ %hash is OK, while %hash ~~ $key is not.
- distributive – applies itself recursively across data structures. Isn’t it getting too smart? And too complex to understand in real code? And too WTFish? I’ll quote the fragment of perl tips newsletter from http://perltraining.com.au/
following expression is *true* when evaluated under 5.10.1, but *false*
‘bar’ ~~ [ ‘foo’, [ ‘bar’, ‘baz’ ], ‘qux’ ]
In the same vein, given the following code:
[ ‘foo’, ‘bar’, ‘baz’ ] ~~ \&subroutine
Perl 5.10.1 will call the subroutine *three* times (once for each
element), and the whole expression will be considered true if *all* the
results are true. On the other hand, Perl 5.10.0 would call the
subroutine only once, passing in the whole data structure.
If you want to make Excel spreadsheet using perl module Spreadsheet::WriteExcel with, for example, orange or yellow backgorund in some cells, you can use the built-in palette, but the colours there may burn your eyes 🙂
How to have nice colours in spreadsheets: use set_custom_color($index, $red, $green, $blue)
my $light_orange = $workbook->set_custom_color(43, 255, 226, 171); my $ligth_yellow = $workbook->set_custom_color(42, 255, 255, 204); my $light_purple = $workbook->set_custom_color(40, 225, 204, 255);
My wife asked me: why did you choose perl? I told her that it is easy and robust, allows quick development, effective writing scripts that will be used just one time etc. To back it, I gave a few examples: when you want to sort, you just use sort, no need to implementing it. When you wat to open file, you just open file. And those regexps – are awesome great.
Then, my wife asked me another question – ok, if it is so great, why do so few people and companies write in it?
This was question I couldn’t find answer for. I told her about that is not so easy to make .exe file from perl script, but as I heard strawberry perl is good in doing it. Or PAR. I’ll have to look closely at them both in near future. Anyway, in C/C++ it is the most natural way to run the program – to make executable of it 🙂 In Perl it is not the natural way. And some companies prefer to have executable files, for example to sell them 🙂
Anyway, that is good question: Why Perl is not so popular as C-something, or java?
Gabor Szabo made a perl ad server, you can display ads to advertise Perl on your website (as I do – you can see them on the right sidebar, if you do not – turn off adblock 🙂 ).
To install this, read more…
Wow,this would be four weeks since joining ironman challenge.
Recently I was wondering about pros and cons of working as Perl developer in two ways:
1) In office, in a big company
2) by telecommuting or other way working in other place that the employer is
They have both advantages and disadvantages.
In office, advantages are: nice colleagues (I am lucky to have them now), free coffe and tea and milk and sugar and…, constant daily routine, a bit of fun/laughing/relax everyday (face it, noone works 100% of the time – it would be also bad for their creativity, physical and mental health etc – for example we are advise to stop looking at minitor every hour for about 5 minutes), fixed hours with some flexibility. Disadvantages: daily commute, trafic jams, earnings based on world region/country, even city.
Telecommute: higher earnings, possiblity to geoarbitrage (I mean earning in one country, living in another – cheaper, or even constantly travel – for more ideas on this see: 4HWW ), no commute, no traffic jams. Disadvantages: I assume you are paid on results – so if you screw up, you have free work overtime. No colleagues, no free coffe nor tea. Your home is your work – that is not good. Unless you rent some office space or use shared working place. Hard to say more, I never worked like this.
What do you think?
This was first time I encountered the strange foreach localisation.
One day I was using global var in script (lame, I know). I wanted to use it in foreach. And its value magically disappeared when called other subroutine. This was strange.
This was a script to make reports for customers. The code looked like this (many parts taken out for brevity and to protect the innocent 😉 ) :
During the YAPC::EU 2009 conference in Lisbon, I heard many times that Perl is NOT dead. Interesting, I never considered Perl to be dead. It is funy thing about human brain, it skips the word NOT. So the message I got is: perl is dead. If so many people try to convince me that “perl is NOT dead”, there has to be a good reason that other people think it IS dead. What can this reason be? Old beliefs about perl? Rise of new languages like python, ruby, groovy?
And, more important for myself – what should I do?
There are several things:
- spread the word that perl is great and not dead, by for example joining ironman blogging chalenge
- wait, and do nothing – if perl is good then it may defend itself without my help
- learn a new language, to be safe. Or brush up old good java or C-something.
What do YOU think about it?