Win has asked for the wisdom of the Perl Monks concerning the following question:
#! perl -w use strict; use warnings; my @files; my @List_of_commands; my $line; my $file; while (<*.sql>) { next if $_ eq 'Activate.sql'; push (@files, $_); } my $line_number; foreach (@files) { print $_; $file = $_; open (FILE, "<$file"); $line_number = 0; while (<FILE>){ my $line = $_; $line_number = $line_number +1; if ($line_number == 1){ if ($line !~ m/ALTER\sPROCEDURE\s/){ #do nothing } else { goto here; } } $line = $_; if ($line =~ m/INSERT INTO Message_pool/){ #Do nothing } elsif ($line =~ m/CREATE TABLE\s([A-Z|a-z|_]{1,200})\s.{0,100}/) { my $table_name = $1; my $Command = "if exists (select 1 from INFORMATION_SCHEMA.table +s where table_name = '".$table_name."') DROP TABLE ".$table_name.""; push(@List_of_commands, $Command); } else { #Do nothing } } here: } my $outfile = "Outfile.txt"; foreach (@List_of_commands){ open (OUTFILE, "+>>$outfile"); print OUTFILE "$_\n" }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: GOTO statement. A better way?
by BrowserUk (Patriarch) on Sep 19, 2005 at 09:38 UTC | |
|
Re: GOTO statement. A better way?
by Corion (Patriarch) on Sep 19, 2005 at 09:26 UTC | |
| |
|
Re: GOTO statement. A better way?
by sh1tn (Priest) on Sep 19, 2005 at 10:37 UTC | |
|
Re: GOTO statement. A better way?
by tilly (Archbishop) on Sep 20, 2005 at 09:03 UTC | |
|
Re: GOTO statement. A better way?
by AReed (Pilgrim) on Sep 19, 2005 at 22:25 UTC |