Posts Tagged ‘Perl’

February 21st, 2007

Mmmm rubygems (0)

Tags: ,

I put together my first ruby gem today (for internal use at work). Here is a good tutorial on how to do it. Or else look at chapter 17 in the Pickaxe book. Simply make a gemspec file, define a few attributes listing and describing your files and then compile it. […]

February 19th, 2007

Vim brute force (0)

Tags: , ,

In the end all code ends up as machine language. Generally the way to write effective code is to use a high-level language and let a smart compiler expand a tiny bit of high-level code it into a great deal of low-level machine language.
But another way I seem to end up doing this is […]

January 11th, 2007

Unique-ify lines in Vim (0)

Tags: , , ,

If I want to get rid of duplicate lines in a text file, in Linux I can simply pipe it through uniq. Windows doesn’t have an equivalent (or else I don’t know about it). There may be a Vim equivalent also, but I don’t know it if there is. Instead you can […]

December 3rd, 2006

Perl vs. Ruby breaking from nested loops (3)

Tags: ,

Breaking out of nested blocks is apparently done much differently in Perl and Ruby. In Perl if you run this:
my $counter = 0;
foreach my $outer (1..5) {
foreach my $inner (’A’..’E') {
print "$outer: $inner\n";
last if […]

November 30th, 2006

One-liner explained (1)

Tags:

Someone asked for an explanation of my obfuscation, so here goes:
The -l flag to Perl makes it stick a newline on the end of output. Handy.
Reformatted and indented, the code would be
for(0..0xb271a1){
++( $} ||= q|A|)
}
( $; = q;"\x70\x72\x69\x6e\x74\x24\x7d"; ) =~ s;.*;$&;eee
A good obfuscation technique is to use odd characters […]

November 29th, 2006

One-liner (1)

Tags:

Been a while since I perl’ed.
perl -le ‘for(0..0xb271a1){++($}||=q|A|)}($;=q;"\x70\x72\x69\x6e\x74\x24\x7d";)=~s;.*;$&;eee’

August 15th, 2006

RubyFacets (0)

Tags: ,

Today I found a really neat site, RubyFacets. Reminds me a bit of Perl’s List::Util and List::MoreUtils; it’s a bunch of methods to extend core classes in interesting ways.
A while back I posted about a way to prevent Ruby from raising an exception when trying to access an un-initialized subarray of a multidimensional array […]

August 14th, 2006

Lisp, part 2 (0)

Tags: , , , ,

Everyone I know who does Lisp says “Learn Lisp and it will change how you look at all other programming languages!” I don’t know if that’s true or not, but I think I’m starting to learn a bit.

August 4th, 2006

Thank you, Google groups (0)

Tags: ,

I just had a nasty run-in with PAR. Activestate Perl doesn’t play as nicely with CPAN as I’d like, so I usually use its own built-in “Perl Package Manager”. The problem with that is that installed packages aren’t rebuilt (from what I can tell), they’re just downloaded in binary form and unpacked. […]

June 27th, 2006

Ruby > Perl (0)

Tags: , ,

A while back I stopped coding in Perl and starting using Ruby for mostly everything. Today I had occassion to use Perl again, because there’s no good working equivalent to Perl’s Spreadsheet::WriteExcel that works well in Ruby; this Ruby spreadsheet package is a bit too buggy. (It’s not my choice to use […]