Offer Kaye wrote:
On 7/5/06, Jeff Peng wrote:

Hello,
I think there are not relation between your implement and the filehandle.

As far as I can tell, a format must have the same name as the
filehandle to which you want to print it, and once you define a format
you cannot change it. So these 2 facts mean you can't have more than 1
format per filehandle. Am I wrong?


You are correct, but who says that you can't have more than one filehandle per file?

    my @list = qw(John Mary Joseph);
    my $ofile = 'o';
    open (FH1, '>', $ofile) or die("Failed to open: $!\n");
    open (FH2, '>&FH1') or die("Dup failed: $!\n");

    write FH1 for (@list);
    write FH2 for (@list);

    close (FH1);
    close (FH2);
    exit;

    format FH1 =
        @|||||||||||||||||||||||||
        $_
.

    format FH2 =
@<<<<<<<<<<<<<<<<<<<<<<
$_
.

So, did you ever look at "perldoc -f open" to see how to duplicate filehandles?



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to