To make the long story short, I have to write a ton on assignments (e.g. id.text = client.id) for our database project. And as it turns out, we also need code which does the assignments the other way around. Too lazy to do it manually, I wrote a short Perl script to do the job:

Perl:

#!/usr/bin/perl
use strict;

my $input;

while( chomp( $input = <STDIN> ) ) {
        $input =~ s/(.*?)(\s*)([^\s=]+?)(\s*)=(\s*)([^\s=;]+)(\s*)(.*?)/$1$2$6$4=$5$3$7$8/;
        print "$input\n";
}

Trackback address for this post

Trackback URL (right click and copy shortcut/link location)

No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)