use strict; use warnings; # no need for your comment! it is clear!! my $outfilename = "pot_temp.txt"; # define an output filename # always check the return values of file operations !!! # there a bunch of syntax'es for this, the main thing is to do it! #open(TFILE,">$outfilename") || die ("unable to open $outfilename $!"); # below I don't use TFILE, this is just a test to stdout #there are shorter ways to do this, but this is staightforward. #Maybe these are pressure increments? And I have wrong name? #whatever, this is one way to do it... my @temp_increments; for (my $i=500; $i<=900 ; $i += 100) { push @temp_increments, $i; } #my @temp_increments = qw( 500, 600, 700, 800, 900); #would be equivalent for example print "What is the temperature (K)?:"; my $T = ; chomp ($T); print "T results are:\n"; foreach my $temp (@temp_increments) { my $theta = $T*((1013/$temp)**(287/1004)); print "temp = $temp theta=$theta \n"; } #Example output...... #C:\TEMP>perl temp.pl #What is the temperature (K)?:26 #T results are: #temp = 500 theta=31.8147304436198 #temp = 600 theta=30.1990838700515 #temp = 700 theta=28.8972548674746 #temp = 800 theta=27.8150092740013 #temp = 900 theta=26.8940943585568