in reply to I know this code could be better...

while(<NODE>){ push(@lines, $_); }
In list context, the diamond operator returns the entire file, so you can avoid the loop:
push( @lines, <NODE> );

In if statements, pull out the common code, so that your code shows the differences, and the reader doesn't have to figure out what's different:
if($is_script eq 'yes'){ middle(); bottom(); } else { top(); middle(); bottom(); }
is better as
top() unless ($is_script eq "yes"); middle(); bottom();

xoxo,
Andy

%_=split/;/,".;;n;u;e;ot;t;her;c; ".   #   Andy Lester
'Perl ;@; a;a;j;m;er;y;t;p;n;d;s;o;'.  #   http://petdance.com
"hack";print map delete$_{$_},split//,q<   andy@petdance.com   >