$res->headers($header_file_content); #### # in whatever package... package HTTP::Response; sub headers { my $obj = shift; my $arg = shift || die "no file nor string, aborted"; my $fh; { no warnings 'io'; # stat might be unsuccessful open $fh, "<", -f $arg ? $arg: \$arg; } while( <$fh>) { chomp; my ($k,$v) = split/:\s+/,$_,2; $obj->header(lc $k, $v); } } package whatever; # back to whatever package