#!/usr/bin/perl use warnings; use strict; use IO::File; my $fh = IO::File->new_tmpfile or die "Unable to make new temp file: $!"; my @data = ; foreach my $line (@data) { chomp $line; my ($first, undef, undef, $last) = split(/\t/, $line); print $fh "$first $last\n"; } #$fh->flush(); $fh->seek(0, 0) or die "Seek: $!"; print <$fh>; $fh->close(); __DATA__ 1 2 3 4 5 6 7 8 9 0 1 2