#!/usr/bin/perl -w use strict; use warnings; use CGI; use Data::Dumper; my $cgi = new CGI; # add the library dir to @INC; use lib do { use Cwd 'realpath'; my ($dir) = __FILE__ =~ m{^(.*)/}; realpath("$dir/library"); }; use feature 'say'; use FindBin '$RealBin'; use lib $RealBin; use lib "$RealBin/library"; print $cgi->header; use HtmlHeader; my %doctypeAndTitle = header(); say $doctypeAndTitle{doctypeAndTitle}; #output inconsistent 1; #### package HtmlHeader; use strict; use warnings; use parent 'Exporter'; our @EXPORT_OK = qw[ header ]; sub header { my $doctypeAndTitle = getDoctypeAndTitle(); my %doctypeAndTitle = ( doctypeAndTitle => $doctypeAndTitle ); return %doctypeAndTitle; } sub getDoctypeAndTitle{ my $doctype = " My Page Title "; return $doctype; } 1;