in reply to Re^2: Quoting in DBI sql query for on the fly query
in thread Quoting in DBI sql query for on the fly query

You write foreach my $line (<DATA>) {, but at that point, you've already read in all of <DATA>, to @lines. What's more, you've already opened a loop over @lines -- foreach $line ( @lines ) {. Finally, you only close one of these two loops.

You need to use strict; and pay attention to what perl tells you when the code fails.