>>>>> "AS" == Andrew Stanley <[EMAIL PROTECTED]> writes:
AS> I currently have a program which wakes up based on a file being
AS> recieved, and needs to parse it out of it's current format into
AS> another format, which gets spit out in multiple files.
AS> In the code (follows) I wanted to have a filehandle doc, which
AS> wrote a file called doc, which referenced an array called @doc.
AS> That way, life is as easy as updating the parser definitions (if,
AS> for example, I want a new file type), and the file creation /
AS> mapping works like magic.
AS> So, I want the list entry in @f to cascade down through -- entry
AS> doc refers to the FH doc, @doc, etc...
use a hash. typeglobs are not meant for use as complex structures. in
fact they are being replaced by (symbol table) hashes in perl6.
AS> Here is the actual piece of code that I wrote:
AS> @f = qw(doc trx mtr act cus trl org);
AS> @refs = map {
AS> $filestr = join("_", ($_, $date, $time, $doc_id));
AS> open($_, " > $path/gaa_$filestr") or die "Unable to open
AS> gaa_$filestr: $!\n";
AS> \*{$_};
AS> } @f;
gack! a hash of file handles is much cleaner. use IO::File or Symbol.pm
to get anonymous fila handles and store them in a hash keyed by the file
name/type.
uri
--
Uri Guttman --------- [EMAIL PROTECTED] ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs -------------------------- http://jobs.perl.org