#!/usr/bin/perl
use strict;
# create data structure
my $LOG = {};
$LOG->{A} = [];
# $LOG->{A}[0] is the same as $LOG->{A}->[0]
# is the same as $$LOG{A}->[0]
# create anonymous file handle
$LOG->{A}[0] = do { local *FH };
# open file for writing, assign to anon file handle
open($LOG->{A}[0], ">dummy.txt") ||
die "Unable to open test file.";
# unable to print directly to the pointer, so we select it instead
select($LOG->{A}[0]);
print <<EOF;
This is a test of the anonymous file handle procedure.
Were this an actual, real-life procedure, instructions
would follow this message.
EOF
# we're done, go ahead and close the sucker
close($LOG->{A}[0]);
Ya with me? :)
|