There is a construct in perl that actually means "between", it is the range operator '..'.
See also the way I opened and read from the file, which is both safer and clearer than what you did, (you can still put the lines in an array by doing: my @lines = <$handle>; and then iterate over the array).open my $handle, "<", $ARGV[0] or die "Couldn't open file: $!"; # safe +r way to open a file for reading. while (<$handle>) { if (/CREATE TABLE/../-----/) # if between CREATE TABLE and ----- { # Some code } }
As for the rest of your script, the bad indentation and poor names make it impossible for me to understand what you are trying to achieve. Please name your arrays to indicate what they contain, like @lines, @cats or @groceryList. And if you have to append numbers to the names of your variables, you are probably doing something wrong.
You do know that s/./ . /g means "replace every character by a space, a dot and a space" don't you?
You may want to read perlopentut, perlreftut and other tutorials.
In reply to Re: between pattern search not working
by Eily
in thread between pattern search not working
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |