[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] closing filehandles, redirecting output?



Hi all,

I'm still working on this storefront, but here's a new brain-twister! This
line of code is suppossed to put the list of available catalogs into %vars.
I believe that it does just that, but it's putting "" into the array.
...
$vars{'menu'} = &getCatalogMenu();
...
...
#The subroutine "getCatalogMenu()" is called...

sub getCatalogMenu {
   local($doc) = '';
   local(@catalogs) = &Catalog::GetCatalogs();
...
...
#Which calls the subroutine "GetCatalogs()"

sub GetCatalogs {
  local($catalog, $product, %catalogs) = ();
  local(@allproducts) = &Object::GetAllObjects();
...
...
#Which calls "GetAllObjects()"

$ROOT_DIR = "/etc/httpd";           # store files relative to document root
$OBJECT_EXT = 'obj';
%OBJECTS = ();                     # object cache, indexed by object ID.

# -- Functions provided ---

# Gets the list of all objects, either from the cache or by reading
# them in from persistant storage (files).
sub GetAllObjects {
   local($filename, $ID);

   # NOTE: These two lines added for flexility in installation.
   local($location) = $ENV{'DOCUMENT_ROOT'} || $ROOT_DIR;
   local($OBJECT_DIR) = "$location/objects"; # persistent object store

   # Open a directory handle.
  local(@files) = <$OBJECT_DIR/*.$OBJECT_EXT>;
  foreach $filename (sort @files) { # Sort file names
      $ID = substr($filename, length($OBJECT_DIR) + 1);  # chop directory
      substr($ID, - (length($OBJECT_EXT) + 1)) = '';     # chop extension
      &GetObject($ID);  # adds to @OBJECTS if not there
  }
   return(values %OBJECTS);
}
...
...
There is a folder called "objects" with four text files with filename
extentions ".obj" in this file each file represents one product. EXAMPLE:

Daybed.obj
Waterbed.obj

The above subroutine should find these files, strip off the directory and
the extension and return the list back to %vars. But it is returning ""
instead. I know this because I inserted a print statement EXAMPLE:

print "(@files)"\n;

Anyone got any ideas?

Thank you for your time!

Robert

________________ The Central Florida Real Estate Server ______________

Robert Stober                                                           (352) 735-2025 Home
WEB: http://www.landrush.com/                           (352) 357-4174 Office
EMAIL: rstober@landrush.com                             (352) 357-1904 Fax

__________ Searchable Database of Florida Real Estate Listings __________