#!/usr/bin/perl -w use strict; use warnings; my ( $county, $year_x, $yr_tot, $production ); my $result = &make_table; print $result; sub make_table { open YEARLY, '>', \$production; print YEARLY " 2001 2002 2003 2004 \n"; while ( ) { ( $county, $year_x, $yr_tot ) = split ' ', $_; if ( $year_x eq "1" || "2" || "3" || "4" ) { $year_x += $yr_tot; write YEARLY; } } return $production; } format YEARLY = @<<<<<<<< @<<<< $county, $year_x . close YEARLY; __DATA__ McMahon 1 9000 McHardy 2 8000 Moonlit 3 7000 Murphie 4 6000 #### 2001 2002 2003 2004 McMahon 9001 McHardy 8002 Moonlit 7003 Murphie 6004