Check for these three things: There must be no space after the << part. There (probably) should be a semicolon at the end. You can't (easily) have any space in front of the tag #### use strict; use warnings; use vars qw($home_fax $Company $position $company_address1 $company_postal1 $company_phone $company_fax); $home_fax = "a"; $Company = "b"; $position = "c"; $company_address1 = "d"; $company_postal1 = "e"; $company_phone = "f"; $company_fax = "g"; section2(); sub section2 { print <<"ENDHTML"; one ENDHTML unless ($home_fax eq "") { print <<"ENDHTML"; two ENDHTML } print <<"ENDHTML"; three ENDHTML unless ($Company eq "") { print <<"ENDHTML"; four ENDHTML } unless ($position eq "") { print <<"ENDHTML"; five ENDHTML } unless ($company_address1 eq "") { print <<"ENDHTML"; six ENDHTML } unless ($company_postal1 eq "") { print <<"ENDHTML"; seven ENDHTML } unless ($company_phone eq "") { print <<"ENDHTML"; eight ENDHTML } unless ($company_fax eq "") { print <<"ENDHTML"; nine ENDHTML } print <<"ENDHTML"; ten ENDHTML } #### C:\WINNT\PROFILES\simonp\DESKTOP>perl test.pl one two three four five six seven eight nine ten C:\WINNT\PROFILES\simonp\DESKTOP>