#!/usr/bin/perl -pi # The -p wraps the following code in a loop for each line, # and the -i tells perl we're editing the file in-place. # Give this program the filename(s) to change as arguments # on the command line. # Extract and update the table name if this is a CREATE TABLE line $table = $1 if (/CREATE TABLE "SO"."([^"]+)"/); # Change the "PRIMARY KEY" bit if we find it. s/(PRIMARY KEY)/CONTRAINT PK_$table $1/;