sz has asked for the wisdom of the Perl Monks concerning the following question:

**newbie warning**

In putting together a one-time tool to stuff some product descriptions into a template, I came up against the following problem. The code below works fine except that the same product description ends up in each file. I used print statments to verify that the the while loop does indeed traverse all the files in the directory. The problem seems to lie in the substitution operation which repeatedly uses the first value of $description for each product page. What am I missing?
open (TEMPLATE, "<$template_file") or die "Can't open $template_file: +$!"; $template = do { local $/; <TEMPLATE> }; close TEMPLATE; opendir (BIN, "$prod_dir") or die "Can't open $dir: $!"; while (defined ($file = readdir BIN)) { next if ($file =~/^\.\.?$/); #skip file starting with periods open (DESCR, "<$prod_dir/$file") or die "could not open $dir/$file +: $!"; $description = do { local $/; <DESCR> }; $template =~ s/%%DESCRIPTION%%/$description/; open (OUTPUT, ">$output_directory/$file.html"); print OUTPUT $template; close OUTPUT; next; } closedir (BIN);