#!/usr/local/bin/perl5 -w
#  Simple substr Example
#
require "cgi-lib.pl"; # Public Domain library to read form data
#
$statusofread =  &ReadParse(*formdata); # read data in associate array formdata
#
if( $statusofread )     { # If $statusofread nonzero, data read OK
        $string = $formdata{"string"}; # The input $string
        $start = $formdata{"start"}; # The input $start
        $length = $formdata{"length"}; # The input $length
}
#
$today =`date`;
chomp($today); # Today's date captured from UNIX
#
print <<EOF; # Start the HTML responding page beginning with HTTP line
Content-Type: text/html

<html>
<head>
<title>This is Result of my substr CGI Script </title>
</head>
<body bgcolor="white" >
<font color=red size=7 >
<pre>
$string
1....5....0....5....0....5....0....5....0....5....0
</pre>
EOF
if( $length ne '' )	{
	$partstring = substr($string,$start,$length);
}
else	{
	$partstring = substr($string,$start);
}
print "Result of substr call is $partstring<br>\n";
print <<EOF; # End HTML Page
</font>
</body>
</html>
EOF
exit; # End Program
