use strict;
use Win32::Clipboard;
our $lcnt = 0;
our $result = "" ;
our $CLIP = Win32::Clipboard();
while (<>) {
if (/\n/) { chop; }
$_ =~ s/\&/&/gi;
$_ =~ s/\</</gi;
$_ =~ s/\>/>/gi;
while (/^\s/) { $_ =~ s/^(\s*)\s/$1 /gi; }
$result .= ($lcnt == 0 ? "<pre class='code'>" : "\n") ;
$result .= $_;
$lcnt ++;
}
$result .= "</pre>";
$CLIP -> Empty();
$CLIP -> Set($result);
print "Result is on the clipboard";
If you're not fluent in PERL, don't even try to understand what it does ... it works :)
4 comments:
Check out one of our posts at Develocity on the same subject:
http://develocity.blogspot.com/2007/03/how-to-post-code-samples-from-visual.html
Thanks for the tip. If I ever decide to install Windows Live Writer (not likely, as I'm moving more and more toward Linux/OpenSource world), I'll definitely use your technique.
Hello Ivan,
I thought you might be interested on a post I just wrote about posting code samples on Blogger.
http://riveradev.blogspot.com/2008/12/public-static-void-main-string-args.html
Cheers!
Looks great. Thanks for the link!
Post a Comment