#! perl -w scipt
Do you really want that shebang line?!?
use strict; use warnings;
Good! But then no need for -w.
my @files; my @List_of_commands; my $line; my $file;
Not that bad, but in Perl one seldom really needs to predeclare a long list of variables; it's better to declare them as close as possible to where they're actually needed.
while (<*.sql>) { push (@files,$_); }
Huh?!? Why not
my @files=<*.sql>;
foreach (@files) {
So why not avoiding to use the intermediate variable @files and just do
for (<*.sql>) { # I never use C<foreach> ;-)
$file = $_;
So why not limiting $file to this this lexical scope? Also it would be better to
open (FILE, "<$file");
Didn't mummy told you to
  1. always check the return value of opens and (somewhat less importantly) also to
  2. use lexical filehandles and
  3. the 3-args form of open?
while (<FILE>){ my $line = $_;
Ditto as above!!
if $line not =~ (/INSERT INTO Message_pool)/{ #Do nothing }
Hmmm sounds Perl6-ish. No, let me see better... oh, it's just a misplaced parenthesis. No, let me see better... they're two misplaced parens. Seems we've found the problem.

Incidentally, if #Do nothing is just a placeholder, then fine. But if you think you want to keep it like that, which is not totally unprobable, taking into account your coding {style,experience} as of what I could see above, then just know that eliminating the whole if statement will do just fine.

All in all I recommend reading some introductory Perl tutorial before going on...

Update: I gave a more comprehensive peek into the rest of your script and I think that it could be rewritten much more simply e.g. along this way:

#!/usr/bin/perl # UNTESTED! use strict; use warnings; open my $out, '>', "outfile.txt" or die "Can't open output file: $!\n"; select $out; @ARGV=<*.sql>; while (<>) { next unless /^.{0,50}CREATE TABLE \s ([A-Z|a-z|_]{5,40}) \s .{1,100}/x; print "if exists (select 1 from INFORMATION_SCHEMA.tables where ta +ble_name = '$1') DROP TABLE '$1'\n"; } __END__
Please note that I tried to keep as close as possible to your logic, but if it were just this functionality that you need, than I just wouldn't open the output file myself and use shell redirection instead. If this is to evolve into something bigger, then plainly ignore this comment! If it is not, then I would leave to the user to specify input and output on the cmd line:
#!/usr/bin/perl -ln use strict; use warnings; BEGIN {@ARGV=map glob, @ARGV} # You're under Win*, aren't you? next unless /$whatever (\w+) $whatever/; print "whatever: $1"; __END__

In reply to Re: if expression by blazar
in thread if expression by Win

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.