<p style="font-size:small;">Content-Length: 2480 | <a href="http://clevelandohioweatherforecast.com//pFad.php?u=" style="font-size:small;">pFad</a> | <a href="http://www.graphviz.org/Misc/pl_from_gprof.pl" style="font-size:small;">http://www.graphviz.org/Misc/pl_from_gprof.pl</a></p>
#!/usr/bin/perl -w
# Courtesy robert.nielsen@everest.com

use strict;
use Data::Dumper;

$Data::Dumper::Purity = 1;
$Data::Dumper::Terse  = 1;

undef $/;
my $in = <STDIN>;
my ($flat, $call_graph, $index_str) = split /\cL/, $in;
my $root = {};

$flat =~ s/^\s*[Ff]lat\s+profile:\s+.*?\s+time\s+seconds\s+seconds\s+calls\s+[Tt]s\/call\s+[Tt]s\/call\s+name\s*\n//s;
my $line;
my $flat_profile = [];
foreach $line (split /\n/, $flat)
{
    if($line =~ m/\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.*)\s*/)
    {
	my $entry = { 'time' => "$1", 'cum_sec' => "$2", 'self_sec' => "$3", 'calls' => "$4", 'self_sec_per_call' => "$5", 'total_sec_per_call' => "$6" , 'name' => "$7" };
	push @$flat_profile, $entry;
    }
    else
    {
    }
}
$$root{flat_profile} = $flat_profile;

$index_str =~ s/^\s*[Ii]ndex\s+by\s+function\s+name\s*//s;
$index_str =~ s/\s*(\[\d+\])/\n$1/g;
$index_str =~ s/^\n+//;

my %index = map { /^(\[\d+\])\s*(.*?)\s*$/ or die; ($1, $2) } split(/\n/, $index_str);

$main::block = qr{
                    \<
                    (?:
                       (?> [^<>]+ )         # Non-framing without backtracking
                       |
                       (?{ $main::block }) # Group with matching framing
                    )*
                    \>
                 }x;
my ($key, $val);
while(($key, $val) = each(%index))
{
    $val =~ s/$main::block/<>/g;
    $index{$key} = $val;
}

#print Dumper \%index;
$$root{index} = \%index;

$call_graph =~ s/^.*?index\s+%\s+time\s+self\s+children\s+called\s+name\n//s;

my @entry = split /-+-\n/, $call_graph;
my $file = [];
my $lines;
my $result = [];

foreach $lines (@entry)
{
    my $result_entry = [];
    my @lines = split /\n/, $lines;
    my $line;
    foreach $line (@lines)
    {
	if($line =~ m/(\[\d+\])\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.*?)\s+(\[\d+\])/)
	{
	    my $entry = { 'time' => "$2", 'self' => "$3", 'children' => "$4", 'called' => "$5", 'name' => "$6", 'index' => "$7" };
	    $$entry{name} =~ s/$main::block/<>/g;
	    push @$result_entry, $entry;
	    #print Dumper $entry;
	}
	elsif($line =~ m/\s+(\S+)\s+(\S+)\s+(\S+)\s+(.*?)\s+(\[\d+\])/)
	{
	    my $entry = {                 'self' => "$1", 'children' => "$2", 'called' => "$3", 'name' => "$4", 'index' => "$5" };
	    $$entry{name} =~ s/$main::block/<>/g;
	    push @$result_entry, $entry;
	    #print Dumper $entry;
	}
	else
	{
	}
    }
    push @$result, $result_entry;
}
$$root{call_graph} = $result;
print Dumper $root;
<!-- URL input box at the bottom -->
<form method="GET" action="">
    <label for="targeturl-bottom"><b>Enter URL:</b></label>
    <input type="text" id="targeturl-bottom" name="u" value="http://www.graphviz.org/Misc/pl_from_gprof.pl" required><br><small>
    <label for="useWeserv-bottom">Disable Weserv Image Reduction:</label>
    <input type="checkbox" id="useWeserv-bottom" name="useWeserv" value="false"><br>
    <label for="stripJS-bottom">Strip JavaScript:</label>
    <input type="checkbox" id="stripJS-bottom" name="stripJS" value="true"><br>
    <label for="stripImages-bottom">Strip Images:</label>
    <input type="checkbox" id="stripImages-bottom" name="stripImages" value="true"><br>
    <label for="stripFnts-bottom">Stripout Font Forcing:</label>
    <input type="checkbox" id="stripFnts-bottom" name="stripFnts" value="true"><br>
    <label for="stripCSS-bottom">Strip CSS:</label>
    <input type="checkbox" id="stripCSS-bottom" name="stripCSS" value="true"><br>
    <label for="stripVideos-bottom">Strip Videos:</label>
    <input type="checkbox" id="stripVideos-bottom" name="stripVideos" value="true"><br>
    <label for="removeMenus-bottom">Remove Headers and Menus:</label>
    <input type="checkbox" id="removeMenus-bottom" name="removeMenus" value="true"><br></small>
<!-- New form elements Sandwich Strip -->
        <label for="start"><small>Remove from after:</label>
        <input type="text" id="start" name="start" value="<body>">
        <label for="end"><small>to before:</label>
        <input type="text" id="end" name="end">
        <input type="checkbox" id="applySandwichStrip" name="applySandwichStrip" value="1" onclick="submitForm()"> ApplySandwichStrip<br></small>
    <button type="submit">Fetch</button>
</form><!-- Header banner at the bottom -->
<p><h1><a href="http://clevelandohioweatherforecast.com//pFad.php?u=" title="pFad">pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <i>Saves Data!</i></a></h1><br><em>--- a PPN by Garber Painting Akron. <b> With Image Size Reduction </b>included!</em></p><p>Fetched URL: <a href="http://www.graphviz.org/Misc/pl_from_gprof.pl" target="_blank">http://www.graphviz.org/Misc/pl_from_gprof.pl</a></p><p>Alternative Proxies:</p><p><a href="http://clevelandohioweatherforecast.com/php-proxy/index.php?q=http://www.graphviz.org/Misc/pl_from_gprof.pl" target="_blank">Alternative Proxy</a></p><p><a href="http://clevelandohioweatherforecast.com/pFad/index.php?u=http://www.graphviz.org/Misc/pl_from_gprof.pl&useWeserv=true" target="_blank">pFad Proxy</a></p><p><a href="http://clevelandohioweatherforecast.com/pFad/v3index.php?u=http://www.graphviz.org/Misc/pl_from_gprof.pl&useWeserv=true" target="_blank">pFad v3 Proxy</a></p><p><a href="http://clevelandohioweatherforecast.com/pFad/v4index.php?u=http://www.graphviz.org/Misc/pl_from_gprof.pl&useWeserv=true" target="_blank">pFad v4 Proxy</a></p>