use strict; use CGI; my @comm = ("header('first')","header('second')"); my $cgi = new CGI; foreach my $comm (@comm) { eval('print $cgi->'.$comm); }