in reply to Getting wierd results when looping through file contents

Somewhat unrelated to the question, but please, please do use here documents.
foreach $table (@tables) { chomp $table; print OUTFILE <<"EOT"; BEGIN DBMS_REPCAT.CREATE_MASTER_REPOBJECT ( gname => 'beastdb_mstr_grp', type => 'TABLE', oname => '$table', sname => '$schema', use_existing_object => TRUE, copy_rows => FALSE); END; / EOT }
Also, there's no reason to slurp the entire input file here.
open (INFILE, "< $infile") or die "Couldn't open $infile: $!"; open (OUTFILE, "> $outfile") or die "Couldn't open $outfile: $!"; chomp, print OUTFILE <<"EOT" while <INFILE>; # shorter version BEGIN DBMS_REPCAT.CREATE_MASTER_REPOBJECT ( gname => 'beastdb_mstr_grp', type => 'TABLE', oname => '$_', sname => '$schema', use_existing_object => TRUE, copy_rows => FALSE); END; / EOT close (INFILE); close (OUTFILE);
Update: If that looks too strange, you might want to do something like:
foreach $table (@tables) { print OUTFILE (map "$_\n", "BEGIN", " DBMS_REPCAT.CREATE_MASTER_REPOBJECT (", " gname => 'beastdb_mstr_grp',", " type => 'TABLE',", " oname => '$table',", " sname => '$schema',", " use_existing_object => TRUE,", " copy_rows => FALSE);", "END;", "/\n", ); }
____________
Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: Getting wierd results when looping through file contents
by Anonymous Monk on Jun 26, 2002 at 16:41 UTC
    Are you really suggesting that your here document version is more readable? Your use of a here document completely messes up the visual organization of the code and is particularly less readable because the contents of the here document itself resembles code and has its own indent structure. This is surely not a case where a plain here document is a good solution.
    A reply falls below the community's threshold of quality. You may see it by logging in.