All right:
-- def_macro eval_inplace
my $count = 0;
$main::c->Set("In place evaluation started. If you wish to disable, pl
+ease copy -- end");
while ($main::c->WaitForChange) {
$count++ % 2 or next;
my $t = $main::c->GetText or next;
last if $t =~ /^-- END/i;
my $to = TempOut->new();
eval { eval "\$\\=\$/;$t;1" or die $@;1 } or $main::c->Set("Error
+executing perl: $@ ($t)") and next;
$main::c->Set($to->as_string);
$to->release;
}
print "Exited successfully, clipcommand returned to normal";
This is definitely a hack and shows why I need to clean up some things. However, if you run the script, copy that macro and copy -- eval_inplace, the macro will see everything you copy as perl code to execute and will dutifully populate the clipboard with its output (or the error it generated). To stop it, copy -- end. Also, you can't promote this macro and expect it to work (like I said, hack =)).
Update: I forgot this part. I have the *nix style shebang line out of habit. I personally use it with ActiveState build 822.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|