Archive for the 'Perl' Category
Thursday, September 21st, 2006
With Bash, you can simply remove duplications by typing:
sort file | uniq
With Perl, it’s more funny. I found those pieces of code in Code Snippets.
Simple ‘Uniq’ code
my @uniq = keys %{{ map { $_ => 1 } @list }};
Another one, more efficient
my %u = ();
@uniqed = grep {defined} map {
[…]
Posted in General, Programming, Perl, UNIX | 6 Comments »
Tuesday, May 23rd, 2006
After having worked on some billions of lines with Perl, I wanted to have fun with that language, very close to “human” English. A quick Google search gave me some crazy poems written in Perl! Yeah, I told you it’s very close.
Here are some example:
http://www.perlguy.com/contest.html
if ((light eq dark) && (dark eq light)
&& ($blaze_of_night{moon} […]
Posted in General, Perl, Fun, Poetry | 1 Comment »
Wednesday, May 10th, 2006
Disclaimer:
A renunciation of any claim to or connection with
Disavowal
A statement made to save one’s ass
That’s not my definition, I found it at the movie “Dogma”.
Anyway, This post doesn’t aim to encourage you to spam else’s blog, but this is a message to those who underestimate the spam effect that shows how easy and simple […]
Posted in General, Perl, WordPress | 4 Comments »
Monday, November 28th, 2005
A Perl script to integrate graphics into a HTML file.
Requires Perl with the following CPAN modules: HTML::TokeParser and MIME::Base64.
Handles HTML and XHTML documents, recognizes GIF, PNG and JPEG graphics, parses full path image files, compatible with standards.
See a live example (the documentation itself) here.
Click here to download the script.
Posted in Programming, Perl, Graphics, W3C, HTML | No Comments »
Friday, November 18th, 2005
The following Perl program loops from 0 to 1 incrementing by 0.1:
perl -e ‘while ($_ < 1.0) { printf(”%.1f\n”,$_); $_+=0.1;}’
Posted in General, Programming, Perl, Shell | 1 Comment »
Monday, October 31st, 2005
Here are some interesting Vim macros you can put on your ~/.vimrc :
To make get an insensitive and “smart” search:
set ignorecase
set smartcase
C file template will be generated when you press F7 button:
map <F7> i#include <stdio.h><CR>int main(int argc, char *argv[])<CR>{<CR><CR>return 0;<CR>}<ESC>
Perl heder, when you press F8:
map <F8> i#!/usr/bin/perl -w<CR><Left><Del>use strict;<CR>use warnings;<CR>use POSIX<ESC;>
Python header, press […]
Posted in General, Perl, C, UNIX, Vim | No Comments »
Sunday, October 23rd, 2005
I have released a quick Perl script to parse an Apache log file and insert data into a SQLite database.
Click here to download the script.
Posted in Programming, Perl, Web Server, Apache, SQLite | No Comments »
Monday, October 17th, 2005
To search and replace a string at the same file with “sed” command, use the -i option:
sed -is ’s/search/replace/g’
The same option can be used for Perl too; this can help a lot:
perl -pie ’s/search/replace/g’
Posted in GNU/Linux, Programming, Perl | No Comments »