http://www.perlmonks.org?node_id=177424


in reply to Getting wierd results when looping through file contents

Each line of the tables file does have a newline at the end, and that newline is at the end of each $table as you go through the loop. The reason the chomp didn't work is because it "returns the total number of characters removed from all its arguments." That's why you're getting a 1.

Thus, all you need to do is change your foreach loop to:

foreach $table (@tables) { chomp $table; print OUTFILE "BEGIN\n"; print OUTFILE " DBMS_REPCAT.CREATE_MASTER_REPOBJECT (\n"; print OUTFILE " gname => 'beastdb_mstr_grp',\n"; print OUTFILE " type => 'TABLE',\n"; print OUTFILE " oname => '$table',\n"; print OUTFILE " sname => '$schema',\n"; print OUTFILE " use_existing_object => TRUE,\n"; print OUTFILE " copy_rows => FALSE);\n"; print OUTFILE "END;\n"; print OUTFILE "/\n\n"; }