text: in the past, i've advocated the use of FileHandle to deal with scoping and stricture issues. i still use FileHandle, but i've come up with another way to avoid namespace pollution -- anonymous subroutines. it doesn't solve stricture problems, but i don't use strict in CGI production code anyway -- it speeds things up quite a bit. i do, and always will, use strict in development (please do the same!)
  attached is a snippet for extracting files from a directory. notice the use of an anonymous subroutine, including passed parameters. i localize the handle within the sub, do my processing, and return an array -- and no messy namespace clutter to worry about later.
  my $dir = '/path/to/files';
  my @files = sub{
  local *DH;
  opendir( DH, $_[0] ) or die 'Cannot open ' . $_[0];
  return grep { -f $_ } readdir(DH);
  }->( $dir );
  my @files = do {
  local *DH;
  opendir( DH, $dir ) or die 'Cannot open ' . $dir;
  grep { -f $_ } readdir(DH);
  };
  [download]
  --
  John.
  my %dispatch = (
  sub_get_files => sub{ # takes one arg
  local *DH;
  opendir( DH, $_[0] ) or die 'Cannot open ' . $_[0];
  return grep { -f $_ } readdir(DH)
  },
  );
  my @files = $dispatch{sub_get_files}->( $dir );
  [download]
  ~Particle *accelerates*
  Thunder fish
  Shocky knifefish
  TBD
  Electric eels were invented at the same time as electricity
  Before electricity was invented, electric eels had to stun with gas
  Results (293 votes). Check out past polls.