#!/usr/bin/perl -w use strict; use IO::File; print "Testing...\n"; my $t1 = '1'; my $t2 = '2'; my $t3 = '3'; my $fh = IO::File->new_tmpfile() or die $!; $fh->format_name("TEST"); select($fh); write(); seek($fh, 0, 0); # Rewind the file my $str = do {local $/; <$fh>}; select(STDOUT); print $str; format TEST= @||| @||| @||| $t1,$t2,$t3 @||| @||| @||| $t3,$t2,$t1 . __END__ Output: Testing... 1 2 3 3 2 1