First, I would like to thank everyone who helped me with the first question on this matter.
Now I have a new question, I can do the matching and changing of the datatypes need. However, I want to restrict this to only CREATE TABLE statements in a file. I have provided the script that works great; just needs to be refined.
I was thinking about encapulating these if-elsif statements in a if statement like so:
if (<some variable> eq "CREATE TABLE") { Do IF-ELSE statements; }
Then close the while loop.
I was woundering if I'm on the right track, if not someone please put be back on.
Code that works
#!/usr/bin/perl -w $gocount=$charcount=0; $numcount=$floatcount=$realcount=0; $datecount=$timestampcount=0; $clobcount=$blobcount=0; $longrawcount=$total=0; print "\nWhat file would you like to open: "; $file = <STDIN>; $file =~ s/[\r\n]+//g; print "\nAttempting to open $file\n"; open(FILE, "< $file") || die "FILE ERROR: Unable to open file: $!\n"; open(OUT, "> new-files/$file") || die"NEW FILE ERROR: Unable to create + new file: $!\n"; while (<FILE>) { if (s/^\s*go\s*$/\/\n/gi) { $gocount++; print OUT "TABLESPACE ARSAMS\n"; #print "$file: found a match\n"; }elsif (s/\bchar\b/VARCHAR2/gi || s/\bvarchar\b/VARCHAR2/gi) { $charcount++; }elsif(s/\bdecimal\b/NUMBER/gi || s/\binteger\b/NUMBER/gi || s +/\bbigint\b/NUMBER/gi || s/\bbit\b/NUMBER/gi || s/\btinyint\b/NUMBER/ +gi || s/\bsmallint\b/NUMBER/gi || s/\bnumeric\b/NUMBER/gi || s/\bmone +y\b/NUMBER/gi) { $numcount++; }elsif(s/\bfloat\b/FLOAT/gi) { $floatcount++; }elsif(s/\breal\b/REAL/gi) { $realcount++; }elsif(s/\bdate\b/DATE/gi || s/\btime\b/DATE/gi || + s/\bsmalldatetime\b/DATE/gi || s/\bdatetime\b/DATE/gi) { $datecount++; }elsif(s/\btimestamp\b/TIMESTAMP/gi) { $timestampcount++; }elsif(s/\blongchar\b/CLOB/gi) { $clobcount++; }elsif(s/\bbinary\b/BLOB/gi || s/\bvar +binary\b/BLOB/gi) { $blobcount++; }elsif(s/\blongbinary\b/LONG RAW/g +i) { $longrawcount++; } $count++; print OUT; } #$gocount+$charcount+$numcount+$floatcount+$realcount+$datecount+$time +stampcount+$clobcount+$blobcount+$longrawcount=$total; print "\nThere are $count LINES in the file\n"; print "Changed $gocount GO in this file\n"; print "Changed $charcount CHAR in this file\n"; print "Changed $numcount NUMBER in this file\n"; print "Changed $floatcount FLOATS in this file\n"; print "Changed $realcount REAL in this file\n"; print "Changed $datecount DATE in this file\n"; print "Changed $timestampcount TIMESTAMP in this file\n"; print "Changed $clobcount CLOB in this file\n"; print "Changed $blobcount BLOB in this file\n"; print "Changed $longrawcount LONG RAW in this file\n"; #print "\nTotal number of changes: $total\n"; close(OUT) || die "Unable to close OUT file: $!\n"; close(FILE) || die "Unable to close file: $!\n";
Someone please help.
Thanks,
Bobby

In reply to Matching Question #2 by curtisb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.