A handy trick for programming perl is the -p flag. This tells perl to surround your code with:
while (<>) {
... # your script goes here
} continue {
print or die "-p destination: $!\n";
}
If you have a file with state names and 2 character codes, like “DE:Delaware”, you could convert that into SQL insert statements by feeding it to a simple perl script like follows:
#!/usr/bin/perl -p -w
s/(.*):(.*)/INSERT INTO states (state_value,state_name) VALUES ('$1','$2');/