in reply to Look Ahead/Behind Via a File Handle

If you have the module that Zaxo mentioned, try using it; if not, try installing it; if that fails, try again.

But if you really have a problem with the module, and you think your task shouldn't be that much work (or you don't have time), you could consider the following approach:

Assuming the huge schema file is written in a consistent manner (suggested by your examples), there are bound to be semicolons at the end of every statement, and end-of-statement is bound to be the only place where semicolon is followed by newline, so use the "input record separator" variable in perl to read a whole statement at a time:

{ $/ = ";\n"; while (<SCHEMA>) { # everything up to/including the next ";\n" has been read into $_ s/\s+/ /g; # normalize all white space to " " if ( /create table (\S+)/ ) { # table definition statement my $tablename = $1; ... } ... } }