$file_name = @ARGV[0]; open (SCHEMA, $file_name); open (BIGLIST, ">>table_names.txt"); open (SMALLLIST, ">>refined_tbl_name.txt"); #open the file while() { $line = $_; #is this a line that declares a new table? if ($line =~ /create table \".+?\"\.(.+?)$/mos) { #if so, print the name into a list print BIGLIST "$1 \n"; #create a new variable that has the name $table_nm = $1; } }