CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: General Discussions: Feedback: Re: [BillKSmith] [perl] doesn't work: Edit Log



Zhris
Enthusiast

Jul 9, 2014, 5:37 PM


Views: 165353
Re: [BillKSmith] [perl] doesn't work

Agreed.

It would be kind of a cool feature though. I have been playing with Syntax::Highlight::Perl this evening, influenced by this post, but the highlighter no longer exists. Perhaps this is something that could be worked on and hosted someplace.


Code
#!/usr/bin/perl 
use strict;
use warnings;
use Syntax::Highlight::Perl;

#####

my $code = <<'CODE';
my $var = 1;
print $var;
CODE

my $colours =
{
Variable => 'red'
};

#####

my $formatter = Syntax::Highlight::Perl->new( );

while ( my ( $type, $colour ) = each ( %$colours ) )
{
$formatter->set_start_format( $type, "[$colour]" );
$formatter->set_end_format( $type, "[/$colour]" );
}

print $formatter->format_string( $code );


Output:


Code
my $var = 1 
print $var;


Could even go as far as for example, pulling out regular expressions and listing their YAPE::Regex::Explain plans underneath in separate code blocks, or tidying up code via Perl::Tidy etc...

Chris


(This post was edited by Zhris on Jul 9, 2014, 5:41 PM)


Edit Log:
Post edited by Zhris (Enthusiast) on Jul 9, 2014, 5:41 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives