<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package Template; 

#/A1z/Html5/Template.pm

=pod

=head1 NAME

HTML5 Template for use in Perl scripts to create web sites easily.

=head1 SYNOPSIS

  my $object = Template-&gt;new(
      foo  =&gt; 'bar',
      flag =&gt; 1,
  );
  
  $object-&gt;dummy;

=head1 DESCRIPTION

Create complete mobile ready web pages/apps easily 
with this HTML5 compatible/enabled interface/module in less than 20 lines!

=head1 METHODS

=cut
 

use 5.10.0;
use strict;
#use warnings; 
# backwards compatibility to 5.6 
# use vars qw(@ISA @EXPORT_OK); 
use parent qw(Exporter); 
require Exporter; 
our @ISA = ("Exporter"); 

our $VERSION = '0.05'; 		# see git branch for latest version.

# http://search.cpan.org/~toddr/Exporter-5.70/lib/Exporter.pm - Why _OK instead of just EXPORT
our @EXPORT_OK = qw(header 
start_html 
head_title head_meta head_js_css end_head 
begin_body body_js_css body_topnavbar body_accordion end_body 
end_html 
); 

=pod

=head2 new

  my $object = Template-&gt;new(
      foo =&gt; 'bar',
  );

The C&lt;new&gt; constructor lets you create a new B&lt;Template&gt; object.

Returns a new B&lt;Template&gt; or dies on error.

=cut

sub new {
	my $class = shift;
	my $self  = bless { @_ }, $class;
	return $self;
}

=pod

=head2 math1

Usage
math1(num1, num2);

=cut

sub math1 
{
	my $self = shift; 
	
	my ($num1, $num2) = @_;
	
	if ($num1 eq '') { $num1 = '2'; }
	if ($num2 eq '') { $num2 = '4'; }
	
	my $out;
	#$out .= "Repeat this line 4 times\n"  x 4 . "\n";
	
	my $m = $num1 * $num2;		# To avoid error: #Argument "Addition 8 + 4 = 8" isn't numeric in addition &lt;+&gt; at Template.PM line 70# do the math in a new var
	my $a  = $num1 + $num2;
	my $s  = $num1 - $num2;
	my $s1 = $num2 - $num1;
	my $d = $num1 / $num2;
	my $d1 = $num2 / $num1;
	
	$out .= qq{&lt;div class="math"&gt;
	&lt;table class="table table-responsive table-bordered table-condensed table-hover"&gt;
	
		&lt;thead&gt;&lt;tr&gt;&lt;td colspan="6"&gt;Multiplication&lt;/td&gt;&lt;/tr&gt;&lt;/thead&gt;
		&lt;tr&gt; 
			&lt;td&gt;&lt;/td&gt;
			&lt;td&gt;$num1&lt;/td&gt; 
			&lt;td&gt;x&lt;/td&gt; 
			&lt;td&gt;$num2&lt;/td&gt; 
			&lt;td&gt;\=&lt;/td&gt; 
			&lt;td&gt;$m&lt;/td&gt; 
		&lt;/tr&gt;
	
		&lt;thead&gt;&lt;tr&gt;&lt;td colspan="6"&gt;Addition&lt;/td&gt;&lt;/tr&gt;&lt;/thead&gt; 
		&lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;$num1 &lt;/td&gt; &lt;td&gt;\+&lt;/td&gt; &lt;td&gt; $num2&lt;/td&gt; &lt;td&gt; \=&lt;/td&gt; &lt;td&gt; $a&lt;/td&gt; &lt;/tr&gt;
		
		&lt;thead&gt;&lt;tr&gt;&lt;td colspan="6"&gt;Subtraction&lt;/td&gt;&lt;/tr&gt;&lt;/thead&gt;
		&lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;$num1&lt;/td&gt; &lt;td&gt; \-&lt;/td&gt; &lt;td&gt; $num2&lt;/td&gt; &lt;td&gt; \=&lt;/td&gt; &lt;td&gt; $s&lt;/td&gt; &lt;/tr&gt;
		&lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;$num2&lt;/td&gt; &lt;td&gt; \-&lt;/td&gt; &lt;td&gt; $num1&lt;/td&gt; &lt;td&gt; \=&lt;/td&gt; &lt;td&gt; $s1&lt;/td&gt; &lt;/tr&gt;
		
		&lt;thead&gt;&lt;tr&gt;&lt;td colspan="6"&gt;Division&lt;/td&gt;&lt;/tr&gt;&lt;/thead&gt;
		&lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;$num1&lt;/td&gt; &lt;td&gt; \/&lt;/td&gt; &lt;td&gt; $num2&lt;/td&gt; &lt;td&gt; \=&lt;/td&gt; &lt;td&gt; $d &lt;/td&gt;&lt;/tr&gt;
		&lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;$num2&lt;/td&gt; &lt;td&gt; \/&lt;/td&gt; &lt;td&gt; $num1&lt;/td&gt; &lt;td&gt; \=&lt;/td&gt; &lt;td&gt; $d1&lt;/td&gt; &lt;/tr&gt;
		
	&lt;/table&gt;
	&lt;/div&gt;
	};

	return qq~\n$out\n~;
}

# begin timestable 
sub timestable 
{	
	my $self = shift;
	
	my ($num1) = @_;
	
	if ( $num1 eq '' ) { $num1 = '2'; }
	
	my $out;
	
	$out .= qq{&lt;table class="table table-bordered table-condensed table-striped table-hover table-responsive"&gt;};
	
	for ('1'..'20') 
	{
		$out .= qq~&lt;tr&gt; &lt;td&gt;$num1&lt;/td&gt; &lt;td&gt;x&lt;/td&gt; &lt;td&gt;$_&lt;/td&gt; &lt;td&gt;=&lt;/td&gt; &lt;td&gt;~ . $num1 * $_ . qq~&lt;/td&gt;&lt;/tr&gt;~ if ($_);
	}
	$out .= qq{&lt;/table&gt;};
	
	return $out;
}
# end timestable 

# begin header 
sub header 
{
	my $self = shift; 
	
	# my %in = (
		# -type =&gt; "Content-Type: text/html",  
		# -char =&gt; "charset=utf-8\n\n", 
		# @_,
		
	# ); 
	
	my @keys; 
	if (@_) { @keys = @_; } 
	
	my $args = scalar(@keys); 
	
	my ($key, $key1) = @_;
	
	my %out;
	
	if ($ARGV and $ARGV &gt; 0 and scalar(@keys) &gt; 0) 
	{
		if ($key eq 'utf8')
		{
			$out{"$key"} = qq~Content-Type: text/html;charset=utf-8\n\n~; 
			
		} 
		elsif (!defined $key or $key eq '') 
		{
			$out{"$key"} = qq~Content-Type: text/html;charset=utf-8\n\n~;
		}
		else 
		{
			$out{"$key"} = qq~Content-Type: text/html;charset=utf-8\n\n~;
		}
	}
	else 
	{
		return qq~Content-Type: text/html;charset=utf-8\n\n~; 
	}
	
} 
# end header 

# begin start html 01
sub start_html  
{ 
	my $self = shift;
	
	my @keys; 
	if (@_) { @keys = @_; } 
	
	my $args = scalar @keys; 
	
	my ($key, $key1) = @_; 
	
	my %out; 
	
	if ($args and $args &gt;= 0) 
	{
		# have your own custom header, backwards compatibility 
		
		my $out; 
		
		$out .= qq~@_ ~; 
		
		return $out; 
		
	}
	else 
	{
		my $out; 
		
		$out .= qq~&lt;!DOCTYPE html&gt; \n&lt;html&gt; \n~;  
		$out .= qq~&lt;head&gt; \n~; 
	
		return $out; 
		
	}
} 
# end start_html 

sub body_js_css 
{
	my $self = shift;
	
	my $key = "@_"; 
	
	my @keys; 
	if (@_) { @keys = @_; } 
	
	my $args = scalar (@keys); 
	
	my $out; 
	
	$out .= qq~&lt;!--jquery--&gt;
&lt;script src="/jquery/jquery-1.11.1.min.js"&gt;&lt;/script&gt;
&lt;!--bootstrap/jQueryUI--&gt;
&lt;script src="/jquery/bootstrap/js/bootstrap.min.js"&gt;&lt;/script&gt;
&lt;script src="/jquery/ui/1.11.2.lightness/jquery-ui.min.js"&gt;&lt;/script&gt;

&lt;!-- IE10 viewport hack for Surface/desktop Windows 8 bug --&gt;
&lt;script type="text/javascript" src="/jquery/bootstrap/fixed-top/ie10-viewport-bug-workaround.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
// for tabs 
\$(function() {
    var tabs = \$( "#tabs" ).tabs();
    tabs.find( ".ui-tabs-nav" ).sortable({
      axis: "x",
      stop: function() {
        tabs.tabs( "refresh" );
      }
    });
  }); 
  
// dialog 
\$(function() {
    \$( "#dialog" ).dialog({
      autoOpen: false,
      show: {
        effect: "blind",
        duration: 1000
      },
      hide: {
        effect: "explode",
        duration: 1000
      }
    });
 
    \$( "#opener" ).click(function() {
      \$( "#dialog" ).dialog( "open" );
    });
  });
  
\$('#menu').menu(); 
\$('#accordion').accordion(); 
\$('#accordion1').accordion(); 
\$('#accordion2').accordion(); 
\$('#accordion3').accordion(); 
\$('#tabs').tabs(); 
//\$('#dialog').dialog(); // no need, is taken care by the animation dialog above.  enabling this will make the dialog appear on load instead of on click of a/the link
&lt;/script&gt;
~; 
	if ( $args ) 
	{
		
		if ( $args &gt;= 0) 
		{
			my $return;
			
			for (@keys ) 
			{
				chomp;
				if ($_ =~ /.js$/)
				{
					$return .= qq~&lt;script type="text/javascript" src="$_"&gt;&lt;/script&gt;\n~; 
				}
				elsif ($_ =~ /.css$/)
				{
					$return .= qq~&lt;link href="$_" rel="stylesheet" style="text/css"&gt;\n~; 
				}
				else 
				{
					# do nothing
					#return qq~&lt;!--213--&gt; @keys\n~; 
				}
			}
			
			return qq~&lt;!--216 jQ--&gt;$return~; 	#
		}
		else 
		{
			return qq~&lt;!--223 noArgs--&gt;$out~; 
		}
		
	}
	else 
	{
		return qq~&lt;!--229 noParams--&gt;$out~; 	# 
	} 
	
} 


# start end_html 
sub end_html 
{ 
	my $self = shift;
	
	my @keys; 
	if (@_) { @keys = @_; } 
	
	my ($key, $key1) = @_;
	
	my $out; 
		
	$out .= qq~&lt;/html&gt;\n\n~;
	
	if ($ARGV and $ARGV &gt; 0 or scalar(@keys) &gt; 0) 
	{
		return qq~@_~;
	}
	else 
	{	
		return $out; 
	}
} 
# end end_html

# start head title 02 
sub head_title
{
	my $self = shift;
	
	my $key = "@_"; 
	
	my @keys; 
	if (@_) { @keys = @_; } 
	
	my $out; 
	
	$out .= qq~~; 
	
	if ($ARGV and $ARGV &gt; 0 or scalar(@keys) &gt; 0) 
	{
		
		if ($key) 
		{
			return qq~&lt;title&gt;@_&lt;/title&gt;\n~; 
		}
		else 
		{
			return qq~&lt;title&gt;Template&lt;/title&gt;\n~; 
		}
		
	}
	else 
	{
		return qq~&lt;title&gt;Package Html5&lt;/title&gt;\n~; 	# this works but does not ask the user
	}
	
} 
# end head title 

# begin head meta 03
sub head_meta
{
	my $self = shift;
	
	my $key = "@_"; 
	
	my @keys; 
	if (@_) { @keys = @_; } 
	
	my $args = scalar @keys; 
	
	my $out; 
	
	$out .= qq~&lt;meta charset="utf-8"&gt;
&lt;meta lang="en"&gt;
&lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt; 
&lt;meta name="HandheldFriendly" content="true"&gt; 
&lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; 
~; 
	
	if ($args) 
	{
		
		if ($args &gt;= 0) 
		{
			my $return;
			
			for (@keys ) 
			{
				chomp;
				
				my ( $meta_name, $meta_cont) = split(/---/, $_, 2);
				
				$return .= qq~&lt;meta name="$meta_name" content="$meta_cont"&gt;\n~; 
			}
			
			return qq~$return&lt;!--360--&gt;~; 
		}
		else 
		{
			$out .= qq~&lt;meta name="description" content="HTML5 by Business Impact Solutions - bislinks.com"/&gt;&lt;!--364--&gt;~; 
			# add default meta if user has not called one of his own
			return qq~$out~; 
		}
		
	}
	else 
	{
		return qq~$out~; 	# this works but does not ask the user
	}
	
} 
# end head meta 03 

# begin body top nav bar
sub body_topnavbar
{
	my $self = shift;
	
	my $key = "@_"; 
	
	my @keys; 
	if (@_) { @keys = @_; } 
	
	my $out; 
	
	$out .= qq~&lt;script type="text/javascript" src="/jquery/top-nav-bar.js"&gt;&lt;/script&gt;
&lt;!--top nav bar begin--&gt;
&lt;script type="text/javascript"&gt;
//&lt;--
fixed_top_navbar('', '', 'Menu', '', '');
//--&gt;
&lt;/script&gt;
&lt;!-- top nav bar end--&gt; 
~; 
	
	if ($ARGV and $ARGV &gt; 0 or scalar(@keys) &gt; 0) 
	{
		
		if ($key) 
		{
			return qq~@_\n~; 
		}
		else 
		{
			return qq~$out\n~; 
		}
		
	}
	else 
	{
		return qq~$out\n~; 	# this works but does not ask the user
	}
	
} 
# end body top nav bar

sub head_js_css
{
	my $self = shift;
	
	my $key = "@_"; 
	
	my @keys; 
	if (@_) { @keys = @_; } 
	
	my $args = scalar (@keys); 
	
	my $out; 
	
	$out .= qq~&lt;!-- Bootstrap/jqueryUI --&gt;

&lt;link href="/jquery/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"&gt;
&lt;link href="/jquery/bootstrap/fixed-top/navbar-fixed-top.css" rel="stylesheet"&gt;
&lt;link href="/jquery/ui/themes/smoothness/jquery-ui.min.css" rel="stylesheet"&gt;
&lt;link href="/jquery/ui/themes/smoothness/theme.css" rel="stylesheet"&gt;

&lt;!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --&gt;
&lt;!--[if lt IE 9]&gt;
&lt;script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"&gt;&lt;/script&gt;
&lt;script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"&gt;&lt;/script&gt;
&lt;![endif]--&gt;

~; 
	
	if ($args) 
	{
		
		if ($args &gt;= 0) 
		{
			my $return;
			
			for (@keys ) 
			{
				chomp;
				if ($_ =~ /.js$/)
				{
					$return .= qq~&lt;!--442--&gt; \n&lt;script type="text/javascript" src="$_"&gt;&lt;/script&gt; \n~; 
				}
				elsif ($_ =~ /.css$/)
				{
					$return .= qq~&lt;!--446--&gt; \n&lt;link href="$_" rel="stylesheet" style="text/css"&gt; \n~; 
				}
				else 
				{
					# do nothing
					return qq~@keys&lt;!--469--&gt;\n~; 
				}
			}
			
			return qq~$return&lt;!--473 jQ--&gt;\n~; 
		}
		else 
		{
			return qq~$out\n~; 
		}
		
	}
	else 
	{
		return qq~$out\n~; 	# this works but does not ask the user
	}
	
} 
# end head js css

# begin end head
sub end_head 
{ 
	my $self = shift;
	
	my $key = "@_"; 
	
	my @keys; 
	if (@_) { @keys = @_; } 
	
	my $out; 
	
	$out .= qq~&lt;/head&gt;~; 
	
	if ($ARGV and $ARGV &gt; 0 or scalar(@keys) &gt; 0) 
	{
		
		if (@_) 
		{
			return qq~@_\n~; 
		}
		else 
		{
			return qq~$out\n~; 
		}
		
	}
	else 
	{
		return qq~$out\n~; 	# this works but does not ask the user
	}
} 
# end end head 


# begin begin body 
sub begin_body 
{ 
	my $self = shift;
	
	my $key = "@_"; 
	
	my @keys;  
	if (@_) { @keys = @_; } 
	
	my $out; 
	
	$out .= qq~&lt;body&gt;~; 
	
	if ($ARGV and $ARGV &gt; 0 or scalar(@keys) &gt; 0) 
	{
		
		if (@_) 
		{
			return qq~@_\n~; 
		}
		else 
		{
			return qq~$out\n~; 
		}
		
	}
	else 
	{
		return qq~$out\n~; 	# this works but does not ask the user
	}
} 
# end begin body

# sub content_via_file {} 

# content_via_file = body_accordian; 

# begin accordion or rather file content.  Need to change name of this method
sub body_accordion 
{

=head1 Usage

	my $h = Template-&gt;new();
	say $h-&gt;body_accordion( $h-&gt;open_file("C:/Users/user/public/app/open_file_example.txt", 'Type', 'Header') ); 

=cut


	my $self = shift;
	
	my $key = "@_"; 
	
	my @keys;  
	if (@_) { @keys = @_; } 
	
	my $out; 
	
	$out .= qq~&lt;!--begin Content--&gt; 
&lt;div id="accordion617" class="accordion"&gt;
	&lt;h3&gt;Who is it for&lt;/h3&gt;
	&lt;div&gt;For those who know/uderstand Perl/HTML/jQuery&lt;/div&gt;
	&lt;h3&gt;What about a bigger number?&lt;/h3&gt;
	&lt;div&gt;Sure.  Use the custom form to get the times table for a number greater than 30?&lt;/div&gt;
	&lt;h3&gt;How about any number/range?&lt;/h3&gt;
	&lt;div&gt;Yes, of course!  Once again, use the custom form bearing the heading "Or enter your own"&lt;/div&gt;
	&lt;h3&gt;Can I customize it for own use?&lt;/h3&gt;
	&lt;div&gt;In that case, you need to purchase the software and/or order a customization&lt;/div&gt;
&lt;/div&gt;

&lt;!--end Content--&gt;
~; 
	
	if ($ARGV and $ARGV &gt; 0 or scalar(@keys) &gt; 0) 
	{
		
		if (@_) 
		{
			return qq~@_\n~; 
		}
		else 
		{
			return qq~\n&lt;!--525--&gt; \n$out\n~; 
		}
		
	}
	else 
	{
		return qq~\n$out\n~; 	#
	}
} 
# end accordion

sub body_article 
{  
	my $self = shift;
	
	my $out;
	
	my %in;
	%in = 
	(
		content =&gt; "",
		type =&gt; "article",
		header =&gt; "Content Header",
		@_,
	);
	
	if ( !defined $in{content} or $in{content} eq '' )
	{
		return qq{
			No Content
		};
	}
	else
	{
		return qq{&lt;article class="container"&gt;&lt;h2&gt;$in{header}&lt;/h2&gt;
			$in{content}
		&lt;/article&gt;
		};
	}
}

# begin begin body 
sub end_body 
{ 
	my $self = shift;
	
	my $key = "@_"; 
	
	my @keys;  
	if (@_) { @keys = @_; } 
	
	my $out; 
	
	$out .= qq~&lt;/body&gt;~; 
	
	if ($ARGV and $ARGV &gt; 0 or scalar(@keys) &gt; 0) 
	{
		
		if (@_) 
		{
			return qq~@_\n~; 
		}
		else 
		{
			return qq~$out\n~; 
		}
		
	}
	else 
	{
		return qq~$out\n~; 	# this works but does not ask the user
	}
} 
# end end body

# begin content folder to select form 
sub body_form 
{
	my $self = shift; 
	
	my $out; 
	
	my @keys;  
	if (@_) { @keys = @_; } 
	
	my ($vars, $vals) = ''; 
	for (@keys) 
	{
		$vars = $_ if ($_ =~ /^vars/); 
		$vals = $_ if ($_ =~ /^vals/); 
	}
	
	my @form_vars = split(/\;/, $vars); 
	
	my @form_vals = split(/\;/, $vals); 
	
	# get params for hidden fields if given 
	my @hidden; 
	if ($form_vars[4] and $form_vars[4] =~ /\,/) 
	{
		 @hidden = split(/\,/, $_) if $_; 
	}
	else 
	{
		@hidden = ("No", "Vals"); 
	}
	
	# if SELECT .... 
	
	my $select; 
	
	if ($form_vars[3] and $form_vars[3] =~ /^select/) 
	{
		# get the params for the form 
		my ($sel_key, $sel_name, $sel_default, $folder_or_file) = split(/\,/, $form_vars[3], 4); 
		$select .= qq~&lt;label for"$sel_name"&gt;$sel_default&lt;/label&gt;
&lt;div class="form-group"&gt;&lt;!--begin select--&gt;
&lt;select name="$sel_name"&gt;
	&lt;option selected value="$sel_default"&gt;$sel_default&lt;/option&gt;
~;
		
		#now open file/folder to fill "options" 
		if ( -f $folder_or_file ) 
		{
			# open as file 
			#$select .= qq~none~; 
		}
		elsif (-d $folder_or_file)
		{
			# open as dir and add all files in it to "options" 
			opendir (D, "$folder_or_file") or print "$!";
			my @dir = readdir(D); 
			close D;
			
			for my $file (@dir)
			{
				next unless $file =~ /[a-zA-Z0-9]/; 
				# comment if your want subfolders also listed 
				next unless -f "$folder_or_file/$file"; 
				# get rid of . and ..
				next if $file =~ /^(\.|\.\.)/; 
				# do not add hidden files to the options list
				next if $file =~ /^\./; 
				#$select .= '  ' x 8 . qq~&lt;option value="$file"&gt;$file&lt;/option&gt;\n~ if $file; 	# ' ' x 8 = 8 spaces 
				
				# get the size of th file 
				my $size = -s "$folder_or_file/$file"; 
				my $original = $size; 
					$size /= 1024; 
					$size /= 1024;
					$size = sprintf "%.2f", $size; 
				$select .= qq~\t&lt;option value="$file"&gt;$file [$size mb]&lt;/option&gt;\n~ if $file; 	# ' ' x 9 #= spaces
			}
		}

$select .= qq~&lt;/select&gt;
&lt;/div&gt;&lt;!--end select--&gt;
~; 
	}
	else 
	{
		# no select
		$select .= qq~~; 
	}
	 
	
	$out .= qq~&lt;form action="$form_vars[2]" method="$form_vars[1]"&gt;~;  
	
		# add hidden fields/values # from $form_vars[4] 
		for (@hidden)
		{
			my ($name, $value) = split(/---/, $_, 2) if $_; 
			$out .= qq~&lt;input type="hidden" name="$name" value="$value"/&gt;\n~ if $_; 
		}
		# add select 
		$out .= qq~$select~;  
	$out .= qq~\n&lt;button type="submit" class="btn btn-default"&gt;Submit&lt;/button&gt;\n&lt;/form&gt;\n\n~; 
	
	return qq~$out~; 
	
	
}

# 

sub defaults_begin
{
	my $self = shift; 
	
	my $out;
	
	$out .= sprintf header(),  
		start_html(),  
		head_title("$_[0]"),  
		head_meta(), 
		head_meta("$_[1]"), 
		head_js_css(),  
		head_js_css("$_[2]"),  
		end_head(),  
		begin_body(),  
		body_topnavbar()
	;
		
		return $out; 
}

sub defaults_end 
{
	my $self = shift; 
	
	my $out;
	
	$out .= sprintf body_js_css(),
		body_js_css("$_[0]"),
		end_body(), 
		end_html() 
	;
	
	return $out;
}



# Begin Fri Mar 13 00:15:20 2015


# HTML 
my %HTML = (
	-defaultjquery =&gt; qq~&lt;script type="text/javascript" src="/jquery/jquery-1.11.1.min.js"&gt;&lt;/script&gt;
&lt;!--bootstrap/jQueryUI--&gt;
&lt;script type="text/javascript" src="/jquery/bootstrap/js/bootstrap.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/jquery/ui/1.11.2.lightness/jquery-ui.min.js"&gt;&lt;/script&gt;
&lt;!-- IE10 viewport hack for Surface/desktop Windows 8 bug --&gt;
&lt;script type="text/javascript" src="/jquery/bootstrap/fixed-top/ie10-viewport-bug-workaround.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
// for tabs 
\$(function() {
    var tabs = \$( "#tabs" ).tabs();
    tabs.find( ".ui-tabs-nav" ).sortable({
      axis: "x",
      stop: function() {
        tabs.tabs( "refresh" );
      }
    });
  }); 
  
// dialog 
\$(function() {
    \$( "#dialog" ).dialog({
      autoOpen: false,
      show: {
        effect: "blind",
        duration: 1000
      },
      hide: {
        effect: "explode",
        duration: 1000
      }
    });
 
    \$( "#opener" ).click(function() {
      \$( "#dialog" ).dialog( "open" );
    });
  });
  
\$('#menu').menu(); 
\$('#accordion').accordion(); 
\$('#accordion1').accordion(); 
\$('#accordion2').accordion(); 
\$('#accordion3').accordion(); 
\$('accordion617').accordion();
\$('#tabs').tabs(); 
&lt;/script&gt;
~,
	 
);

sub html_bootstrap_css   
{
	return qq~&lt;!-- Bootstrap/jqueryUI --&gt;
&lt;link href="/jquery/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"&gt;
&lt;link href="/jquery/bootstrap/fixed-top/navbar-fixed-top.css" rel="stylesheet"&gt;
~;  
}

sub html_jqueryui_css 
{
	return qq~&lt;link href="/jquery/ui/themes/smoothness/jquery-ui.min.css" rel="stylesheet"&gt;
&lt;link href="/jquery/ui/themes/smoothness/theme.css" rel="stylesheet"&gt; 
~; 
}

sub html_shim_respond 
{
	return qq~&lt;!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --&gt;
&lt;!--[if lt IE 9]&gt;
&lt;script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"&gt;&lt;/script&gt;
&lt;script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"&gt;&lt;/script&gt;
&lt;![endif]--&gt;
~;

}

sub html_navbar 
{
	#my $self = shift; 
	
	my %i;
	%i = (
		-nbmenu 	=&gt;	"", 
		-nbpage 	=&gt; 	"",
		-nbpage1    =&gt;  "",
		-nbmenu1    =&gt;  "",
		@_,		
	);
	
	return qq~&lt;script type="text/javascript" src="/jquery/top-nav-bar.js"&gt;&lt;/script&gt;
&lt;!--top nav bar begin--&gt;
&lt;script type="text/javascript"&gt;
//&lt;-- 
//fixed_top_navbar('$i{-nbpage1}', '', '$i{-nbmenu1}', '', '');
fixed_top_navbar('$_[0]', '', '$_[1]', '', '');
//--&gt;
&lt;/script&gt;
&lt;!-- top nav bar end--&gt; 
~; 

}


sub html_bootstrap_js  
{
	return qq~&lt;!-- Bootstrap/jqueryUI --&gt;
&lt;link href="/jquery/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"&gt;
&lt;link href="/jquery/bootstrap/fixed-top/navbar-fixed-top.css" rel="stylesheet"&gt;
&lt;link href="/jquery/ui/themes/smoothness/jquery-ui.min.css" rel="stylesheet"&gt;
&lt;link href="/jquery/ui/themes/smoothness/theme.css" rel="stylesheet"&gt;
&lt;!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --&gt;
&lt;!--[if lt IE 9]&gt;
&lt;script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"&gt;&lt;/script&gt;
&lt;script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"&gt;&lt;/script&gt;
&lt;![endif]--&gt;
~; 

}

sub html_js_css 
{
	
}

sub html_jquery 
{
	
}

sub html_humanejs_css
{
	return qq~&lt;link rel='stylesheet' href='/jquery/humane-js/themes/bigbox.css'&gt;
      &lt;link rel='stylesheet' href='/jquery/humane-js/themes/boldlight.css'&gt;
      &lt;link rel='stylesheet' href='/jquery/humane-js/themes/jackedup.css'&gt;
      &lt;link rel='stylesheet' href='/jquery/humane-js/themes/libnotify.css'&gt;
      &lt;link rel='stylesheet' href='/jquery/humane-js/themes/original.css'&gt;
&lt;link rel='stylesheet' href='/jquery/humane-js/themes/flatty.css'&gt;
&lt;link href='http://fonts.googleapis.com/css?family=Ubuntu&amp;v2' rel='stylesheet' type='text/css'&gt;
&lt;link href='http://fonts.googleapis.com/css?family=Ubuntu+Mono' rel='stylesheet' type='text/css'&gt;
&lt;link href='http://fonts.googleapis.com/css?family=Cabin+Sketch:700&amp;v2' rel='stylesheet' type='text/css'&gt;
~; 
}

sub html_bootstrap_bluimp 
{
	return qq~&lt;!-- The Bootstrap Image Gallery lightbox, should be a child element of the document body --&gt;
		&lt;div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls" data-use-bootstrap-modal="false"&gt;
	    &lt;!-- The container for the modal slides --&gt;
	    &lt;div class="slides"&gt;&lt;/div&gt;
	    &lt;!-- Controls for the borderless lightbox --&gt;
	    &lt;h3 class="title"&gt;&lt;/h3&gt;
	    &lt;a class="prev"&gt;‹&lt;/a&gt;
	    &lt;a class="next"&gt;›&lt;/a&gt;
	    &lt;a class="close"&gt;×&lt;/a&gt;
	    &lt;a class="play-pause"&gt;&lt;/a&gt;
	    &lt;ol class="indicator"&gt;&lt;/ol&gt;
	    &lt;!-- The modal dialog, which will be used to wrap the lightbox content --&gt;
	    &lt;div class="modal fade"&gt;
	        &lt;div class="modal-dialog"&gt;
	            &lt;div class="modal-content"&gt;
	                &lt;div class="modal-header"&gt;
	                    &lt;button type="button" class="close" aria-hidden="true"&gt;&amp;times;&lt;/button&gt;
	                    &lt;h4 class="modal-title"&gt;&lt;/h4&gt;
	                &lt;/div&gt;
	                &lt;div class="modal-body next"&gt;&lt;/div&gt;
	                &lt;div class="modal-footer"&gt;
	                    &lt;button type="button" class="btn btn-default pull-left prev"&gt;
	                        &lt;i class="glyphicon glyphicon-chevron-left"&gt;&lt;/i&gt;
	                        Previous
	                    &lt;/button&gt;
	                    &lt;button type="button" class="btn btn-primary next"&gt;
	                        Next
	                        &lt;i class="glyphicon glyphicon-chevron-right"&gt;&lt;/i&gt;
	                    &lt;/button&gt;
	                &lt;/div&gt;
	            &lt;/div&gt;
	        &lt;/div&gt;
	    &lt;/div&gt;
	&lt;/div&gt;
	~;
}
# end sub html_bootstrap_bluimp 

sub head 
{
	my $self = shift; 
	
	my $out; 
	
	my %in = (
		-type 	=&gt; "Content-Type: text/html;charset=utf-8\n\n", 
		-bootstrap 	=&gt; html_bootstrap_css, 
		-jqueryui 	=&gt; html_jqueryui_css, 
		-htmlshim	=&gt; html_shim_respond, 
		-humanejs  =&gt; html_humanejs_css, 
		-title 		=&gt; "Page Title", 
		-cssLinks =&gt; "", 
		-cssCode =&gt; "", 
		-mobilemeta =&gt; qq~&lt;meta name="HandheldFriendly" content="true"&gt;
&lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;~, 
		-charsetmeta =&gt; qq~&lt;meta charset="utf-8"&gt;~, 
		-usermeta =&gt; "",
		@_,
		
	); 
	
	for (keys %in) 
	{
		#$out .= qq~$in{$_}\n~;  # disordered 
		
	}

# css multiple links/files 
my $css; my @css; 
if ($in{-cssLinks} )
{
	if  ( $in{-cssLinks} =~ /\,/ ) 
	{
		@css = split(/\,/, $in{-cssLinks});
		for (@css) 
		{
			if ($_ =~ /\.css$/) 
			{
				$css .= qq~&lt;link type="text/css" rel="stylesheet" href="$_"&gt;\n~ ; 
			}
			else 
			{
				$css = ''; 
			}
		}
	}
}
else 
{
	$css = qq~~; 
}


	return qq~$in{-type}&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;$in{-title}&lt;/title&gt; 
$in{-charsetmeta}
$in{-mobilemeta}
$in{-usermeta}
$in{-bootstrap} 
$in{-jqueryui} 
$in{-htmlshim} 
$in{-humanejs}
$css
&lt;style type="text/css"&gt;
$in{-cssCode}
&lt;/style&gt;
&lt;/head&gt;
~; 	# thats orderly 

}
# end head 

sub body 
{
	my $self = shift; 
	
	my $out; 
	
	my %in; 
	
	%in = (
		-h1		=&gt; qq~$ENV{SERVER_NAME}~,
		-onload =&gt; qq~setTitle();~,  
		-nbhead 	=&gt; qq~~,
		-nbpage =&gt; qq~~, 
		-nbmenu =&gt; qq~~, 
		-defaultjquery =&gt; qq~$HTML{-defaultjquery}~, 
		-humanejs =&gt; qq~&lt;script type="text/javascript" src="/jquery/js/humane-js/humane.min.js"&gt;~, 
		-userjquery =&gt; qq~~, 
		-navbar =&gt; html_navbar( $in{-nbmenu}, $in{-nbpage}, "Obselete Thu Mar 26 10:03:47 2015") , 
		-content =&gt; qq~&lt;div class="content"&gt;Content&lt;/div&gt;~, 
		-footer =&gt; qq~All rights reserved &amp;copy; $ENV{SERVER_NAME}~, 	
		-bootstrapbluimp =&gt; html_bootstrap_bluimp, 	
		@_, 		
	); 
	
	return qq~&lt;body onload="$in{-onload}"&gt;
&lt;div id="main" class="container"&gt;
		&lt;script type="text/javascript" src="/jquery/utils/top-nav-bar.js"&gt;&lt;/script&gt;
&lt;!--top nav bar begin--&gt;
&lt;script type="text/javascript"&gt;
//&lt;-- 
fixed_top_navbar('$in{-nbhead}', '$in{-nbpage}', '$in{-nbmenu}', '', '');
//--&gt;
&lt;/script&gt;

$in{-bootstrapbluimp}

	&lt;div class="content"&gt;$in{-content}&lt;/div&gt;
	&lt;div class="footer"&gt;$in{-footer}&lt;/div&gt;
&lt;/div&gt;

$in{-defaultjquery}

$in{-humanejs}
 
&lt;script type="text/javascript"&gt;
//&lt;!--
$in{-userjquery}
//--&gt; 
&lt;/script&gt;

&lt;/body&gt;
	
&lt;/html&gt;
	
~; 

}
# end body 



=pod

=head1 SUPPORT

Support via email only: &lt;perl-cpan at bislinks.com&gt;

=head1 AUTHOR

Copyright 2012 Anonymous.

=cut


sub create_accordion 
{
	my $out; 
	
	my $file = "@_"; 
	
	my @data; 
	
	if ($file and -e -f $file) 
	{ 
		$out .= open_file("$file");
	} 
	else 
	{
		$out .= qq~#55 Unable to open file $file~; 
	
	}
	
	return $out; 
	
} 
# end create accordion



sub open_file 
{
	my $self =shift;
	
	# OUTPUT FORMAT OPTIONS: table, accordion, menu, as is; where "as is" is the default
	
	my $file = "$_[0]"; 			# do not use @_ for a scalar: it puts all together and the file path was wrong.  # use $_[n] # use $_ if and only if there will be just one var passed to this sub
	
	my $output_format = "$_[1]"; 	
	
	my $output_header = "$_[2]"; 
	
	my $out; 
	
	my @data; 
	
	if (open(FILE, "$file") )
	{
		#open(FILE, "$file") or $out .= qq~77 $!~; 
		
		@data = &lt;FILE&gt;; 
		
		$out .= qq~\n&lt;!--begin file output--&gt;\n&lt;div class="file_output"&gt;\n~; 
		
		# Step 1 
		# set the header as per format  
		if ($output_format eq 'table') 
		{ 
			$out .= qq~&lt;table class="table table-striped table-bordered table-hover table-condensed table-responsive"&gt;
				&lt;thead&gt;
					&lt;tr&gt;&lt;th colspan="2"&gt;$output_header&lt;/th&gt;&lt;/tr&gt;
				&lt;/thead&gt;
				&lt;tbody&gt;
			~; 
		}
		elsif ($output_format eq 'accordion')
		{
			$out .= qq~&lt;h2&gt;$output_header&lt;/h2&gt;\n&lt;div id="accordion2" class="accordion"&gt;&lt;!--118--&gt;\n~;
		} 
		elsif ($output_format eq 'menu') 
		{
			$out .= qq~&lt;ul class="menu" id="menu"&gt;\n&lt;li&gt;&lt;a href="/"&gt;$output_header&lt;/a&gt;\n&lt;ul&gt;~;
		}
		elsif ($output_format eq 'tabs')
		{
			# special case for tabs since the data needs to be formatted a little differently 
			
			$out .= qq~&lt;h2&gt;$output_header&lt;/h2&gt;\n&lt;div id="tabs"&gt;\n&lt;ul&gt;\n~;
			
			my $sl = '0'; 
			
				foreach my $line (@data) 
				{
					$sl++ if $line; 
					
					my ($h1, $div) = (''); 
					
					if ($line =~ /\|/) 		
					{ 
						($h1, $div) = split(/\|/, $line, 2); 
					} 			# no (\|) # i.e., no enclosing with brackets.  was the culprit 
					elsif ($line =~ /\t+/) { 
						($h1, $div) = split(/\t+/, $line, 2); 
					} 
					elsif ($line =~ /\s+/) 
					{ 
						($h1, $div) = split(/\s+/, $line, 2); 
					}
					
					# Keep only those items that have '\s+==' in the beginning 
					# next unless ($h1 =~ /^#/ or $div =~ /^#/); 
					# $h1 =~ s!^#!!g;
					# $div =~ s!^#!!g; 
					
					next unless ($h1 =~ /^\s+==/ or $div =~ /^\s+==/); 
					$div =~ s~^\s+==~~g; 
					$h1 =~ s~^\s+==~~g; 
					$out .= qq~\t&lt;li&gt;&lt;a href="#tabs-$sl"&gt;$h1&lt;/a&gt;&lt;/li&gt;\n~; 
				}
			$out .= qq~&lt;/ul&gt;\n~; 
		}
		elsif ($output_format eq 'dialog')
		{
			$out .= qq~&lt;h2&gt;Dialog: &lt;a href="#opener" id="opener" title="Opens the Dialog"&gt;$output_header&lt;/a&gt;&lt;/h2&gt;
&lt;div id="dialog"&gt;\n~; 
		}
		else 
		{
			$out .= qq~\n&lt;h2&gt;$output_header&lt;/h2&gt;\n~; 
		}
		# End Step 1
		
		# now work on file 
		
		my $serial = '0'; 
		
		foreach my $line (@data) 
		{ 
			chomp $line; 
			
			$serial++ if $line; 
			
			my ($h1, $div) = (''); 
			
			if ($line) 				# make sure no output if line is empty
			{	
				$line =~ s! RN !\r\n!g;
				
				# split the file's lines into usable data according to separator used.
				if ($line =~ /\|/) 		
				{ 
					($h1, $div) = split(/\|/, $line, 2); 
				} 			# no (\|) # i.e., no enclosing with brackets.  was the culprit 
				elsif ($line =~ /\t+/) { 
					($h1, $div) = split(/\t+/, $line, 2); 
				} 
				elsif ($line =~ /\s+/) 
				{ 
					($h1, $div) = split(/\s+/, $line, 2); 
				}
				# end split the file's line according to match: 3 options: |, \t+, or \s+ 

			}
			
			#$out .= qq~\t&lt;h3&gt;$h1&lt;/h3&gt;\n\t&lt;div&gt;$div&lt;/div&gt;\n~ if $line;  	# old way
			
			# Step 2 
			#Now set the content as per output format 
			if ($output_format eq 'table') 
			{ 
				# Keep only those items that have a # in the beginning 
				next unless ($h1 =~ /^\s+#/ or $div =~ /^\s+#/); 
				$div =~ s!^\s+#!!g;
				$h1 =~ s!^\s+#!!g;
				$out .= qq~\t&lt;tr&gt;&lt;td&gt;$h1&lt;/td&gt;&lt;td&gt;$div&lt;/td&gt;&lt;/tr&gt;\n~; 
			}
			elsif ($output_format eq 'accordion')
			{
				# Keep only those items that have a # in the beginning 
				# next unless ($h1 =~ /^#/ or $div =~ /^#/); 
				# $div =~ s!^#!!g; 
				# $h1 =~ s!^#!!g; 
				
				next unless ($h1 =~ /^\s+--/ or $div =~ /^\s+--/); 
				$div =~ s~^\s+--~~g; 
				$h1 =~ s~^\s+--~~g; 
				
				# next unless ($h1 =~ /^*/ or $div =~ /^*/); 
				# $div =~ s~^*~~g; 
				# $h1 =~ s~^*~~g; 
				
				$out .= qq~\t&lt;h3&gt;$h1&lt;/h3&gt;\n\t&lt;div&gt;$div&lt;/div&gt;\n~ if $line; 
			} 
			elsif ($output_format eq 'menu') 
			{
				# the first item will be used as link title and name
				# the second item will be used as the actual link  
				# no extensions added automatically by the script 
				# an id for each link/li is also provided in case, may be it is not needed 
				
				# Remove items with a # in the beginning; Sat Feb 21 18:48:19 2015
				next if ($h1 =~ /^#/ or $div =~ /^#/); 
				next unless ($h1 =~ /^\s+http/ or $div =~ /^\s+http/); 
				$out .= qq~\t&lt;li id="li-$serial"&gt;&lt;a id="a-$serial" href="$div" title="$h1"&gt;$h1&lt;/a&gt;&lt;/li&gt;\n~;
			}
			elsif ($output_format eq 'tabs') 
			{
				# Keep only those items that have a # in the beginning 
				# next unless ($h1 =~ /^#/ or $div =~ /^#/); 
				# $div =~ s!^#!!g;
				# $h1 =~ s!^#!!g; 
				
				next unless ($h1 =~ /^\s+==/ or $div =~ /^\s+==/); 
				$div =~ s~^\s+==~~g; 
				$h1 =~ s~^\s+==~~g; 
				
				$out .= qq~\t&lt;div id="tabs-$serial"&gt;&lt;p&gt;$div&lt;/p&gt;&lt;/div&gt;\n~; 
			}
			elsif ($output_format eq 'dialog')
			{
				next unless ($h1 =~ /^\s+#/ or $div =~ /^\s+#/); 
				$div =~ s!^\s+#!!g;
				$h1 =~ s!^\s+#!!g;
				$out .= qq~&lt;p&gt;$h1&lt;/p&gt;\n&lt;p&gt;$div&lt;/p&gt;\n~; 
			}
			else 
			{
				$out .= qq~$h1 $div~; 	# or $line
			}
		} 
		
		# add an extra item at the end of file output
		#$out .= qq~\t&lt;h3&gt;Powered by Business Impact Solutions&lt;/h3&gt;\n\t&lt;div&gt;bislinks.com, bizImpactSolutions.com - Business Impact Solutions&lt;/div&gt;\n~; 
		
		# Step 3 
		# set the output ending as per format  
		if ($output_format eq 'table') 
		{ 
			$out .= qq~\n&lt;/tbody&gt;\n&lt;/table&gt;\n\n~; 
		}
		elsif ($output_format eq 'accordion')
		{
			$out .= qq~\n&lt;!--end accordion--&gt;&lt;/div&gt;\n\n~;
		} 
		elsif ($output_format eq 'menu') 
		{
			$out .= qq~&lt;/ul&gt;&lt;/ul&gt;~;
		}
		elsif ($output_format eq 'tabs')
		{
			$out .= qq~&lt;/div&gt;&lt;!--end tabs--&gt;\n~; 
		}
		elsif ($output_format eq 'dialog') 
		{
			$out .= qq~&lt;/div&gt;&lt;!--end dialog--&gt;\n~; 
		}
		else 
		{
			$out .= qq~\n\n~; 
		}
		
		# end file output wrapper
		$out .= qq~&lt;/div&gt;&lt;!--end file output--&gt;\n~; 
		
		close FILE; 
		
		return $out; 
	}
	else 
	{
		my $out;
		
		@data = &lt;DATA&gt;; 
	
		$out .= qq~\n&lt;!--begin accord 112--&gt;\n&lt;div id="accordion1460" class="accordion"&gt;\n~; 
		foreach my $line (@data) 
		{ 
			chomp $line; 
			
			my ($h1, $div) = (''); 
			
			($h1, $div) = split(/\t+/, $line, 2) if $line; 
			
			$out .= qq~\t&lt;h3&gt;$h1&lt;/h3&gt;\n\t&lt;div&gt;$div&lt;/div&gt;\n~ if $line; 
		} 
		$out .= qq~\t&lt;h3&gt;Powered by&lt;/h3&gt;\n\t&lt;div&gt;Package HTML5&lt;/div&gt;\n~; 
		
		$out .= qq~&lt;/div&gt;\n&lt;!--end accord--&gt;\n~; 
		
		return $out; 
	}
	
}
# end open_file


sub edit_file
{
	my $self = shift;
	
	my $out;
	
	my %in;
	
	%in = (
		file =&gt; "",
		error =&gt; "",
		action =&gt; "TemplateAdmin.cgi",
		serial =&gt; '', 
		output_type =&gt; '',
		@_,
	);
	
	if (-e -f "$in{file}")
	{
		open(FILE, "$in{file}") or $in{error} = "unable to open $in{file}";
		my @file = &lt;FILE&gt;;
		close FILE;
		
		$out .= qq{
		&lt;article class="container"&gt;
		
			&lt;h3&gt;Add New Item&lt;/h3&gt;
			&lt;div&gt;
				&lt;a href="$in{action}?action=newItem" title="Add new item"&gt;Add New Item&lt;/a&gt; 
			&lt;/div&gt;

			&lt;h3&gt;Edit Items&lt;/h3&gt;
			
			&lt;form action="$in{action}" method="post"&gt;
			&lt;input type="hidden" name="action" value="write"&gt;
		};
		
		for (@file)
		{
			chomp;
			
			next if $_ =~ /^$/;
			
			$in{serial}++ if $_;
			
			my ( $type, $content ) = split(/\|/, $_, 2);
			
			$type =~ s!\s+$!!g;
			
			my $identifiers = substr "$content", 0, 4;	# has to be 4 to cover 'http.'  Also, assuming no spaces in the beginning (removed by write_file)
			
			# determine output type
			if ( $identifiers =~ /^\#/ ) { $in{output_type} = 'Table'; }
			elsif ( $identifiers =~ /^\-/ ) { $in{output_type} = 'Accordion'; }
			elsif ( $identifiers =~ /^\=/ ) { $in{output_type} = 'Tabs'; }
			elsif ( $identifiers =~ /^http/ ) { $in{output_type} = 'Menu'; }
			else { $in{output_type} = 'None'; }
			
			# remove all nonmeta characters for web page display 
			$identifiers =~ s!(\s+|[a-zA-z0-9])!!g;	# removes http also.
			
			$content =~ s!\&lt;!&amp;lt\;!g;
			$content =~ s!\&gt;!&amp;gt\;!g;
			
			$content =~ s! RN !\r\n!g; # &amp;#13;&amp;#10;
			
			$out .= qq`&lt;div&gt;
				&lt;span class="serial"&gt;$in{serial} &lt;/span&gt; 
				&lt;span class="type"&gt;$type &lt;/span&gt; 
				&lt;span class="identifiers"&gt;$identifiers &lt;/span&gt;
				&lt;span class="output_type"&gt;Type:$in{output_type} &lt;/span&gt;
			&lt;/div&gt;
			&lt;div&gt;
				&lt;textarea name="ta-$type" id="ta-$type" rows="5" cols="98%"&gt;$type , $content&lt;/textarea&gt;
			&lt;/div&gt;
				&lt;br/&gt;
			`;
		}
		
		$out .= qq{&lt;input type='submit' value="Save"&gt;&lt;/form&gt;&lt;/article&gt;};
		
		
		return $out;
		
	}
}


sub write_file
{
	my $self = shift;
	
	my $out; 
	
	my %in;
	%in = 
	(
		file =&gt; "",
		error =&gt; "",
		powershell =&gt; "C:/WINDOWS/system32/WindowsPowerShell/v1.0/powershell.exe ",
		@_,
	);
	
	my %vars;
	
	use CGI;
	my $q = new CGI;
	%vars = $q-&gt;Vars();
	
	my $action = $q-&gt;param('action');
	
	if ( $action eq 'write')
	{

		if (-e -f "$in{file}")
		{
			
			# First, get file content to backup to another file
			open(F, "$in{file}") or $in{error} .= "#1565 Unable to open file for reading. '$!' &lt;br/&gt;";
			my @f = &lt;F&gt;;
			
			# save original file content to backup file
			open(BAK, "&gt;$in{file}.bak.txt") or $in{error} .= "#1570 Unable to create backup file '$in{file}.bak.txt' '$!' &lt;br/&gt;";
			for (@f)
			{
				print BAK qq{$_};	
			}
			close BAK;
			
			close F;
			
			# recreate file, thereby deleting original content 
			open(DEL, "&gt;$in{file}") or $in{error} .= "#1579 Unable to recreate file '$in{file}' '$!' &lt;br/&gt;";
			print DEL "File ReCreated";
			close DEL;
			
			my %out;
			for (keys %vars)
			{
				chomp $_; 
				chomp $vars{$_}; 
				
				next if $_ eq 'action';
				my ( $name, $value ) = split(/\,/, $vars{"$_"}, 2);
				
				$name =~ s!(\r\n+|\n+)! RN !g;
				$value =~ s!(\r\n+|\n+)! RN !g;
				
				$value =~ s!^\s+!!g;
				
				$out{"$name"} = "$value";
			}			
			
			# Insert/Add new content
			open(FILE, "&gt;$in{file}") or $in{error} .= "#1582 Error writing to file '$in{file}' '$!' &lt;br/&gt;";			
			for (keys %out) 
			{
				print FILE qq{$_\|$out{$_}\n};
			}
			close FILE;
			
			
			if (-e -f "$in{file}.bak.txt" and -e -f "$in{file}")
			{	
				return "&lt;div class='success'&gt;Saved&lt;/div&gt; &lt;div class='error'&gt;$in{error}&lt;/div&gt;";
			}
			else
			{
				return "&lt;div&gt;#1605 Error saving file '$in{file}'&lt;/div&gt; &lt;div class='error'&gt;$in{error}&lt;/div&gt;";
			}
		}
		else
		{
			return "File not found";
		}
	}
	elsif ( $action eq 'newItem' )
	{
		return "$action";
	}
	else
	{
		return '* ' x 50;
	}
	
}


1; 
</pre></body></html>