Too Cool for Internet Explorer


Swobodin's Profile | Swobodin's Blog | Back to Fedora Tunisia

Archive for the 'Perl' Category

Perl uniq array, to remove duplications

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 {
[…]

Perl Poetry

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} […]

Spamming Blogs — Howto

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 […]

GraphInside

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.

Simple Perl loop script

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;}’

Vim Macros

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 […]

Log2SQLite 0.1

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.

Search’n'Replace

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’


Top Tunisie Blogs