Can anyone think of a nicer way to do this?
:) Tnx.
eval('0 and eval(\'def length(x) end\')');
0 and length <<2;
""" #"
2
BEGIN{ eval('$stdin') ? "" : eval('package _X;use Filter::Simple sub {
s{^(.*?\n__END_OF_RUBY__[^;]+;)}{do{my $x="$1";$x=~ tr/\n/ /c;$x}}se;
s{(\n#__END_OF_PERL__.*)}{do{my $x="$1";$x =~ tr/\n/ /c;$x}}se;};
package main;import _X;'); }
# END OF CRUFT
def hello()
print "Hi there ruby!\n";
end
hello();
__END_OF_RUBY__ = <<'#__END_OF_PYTHON__';
sub hello {
print "Hi there perl!\n";
}
hello();
#__END_OF_PERL__
""" #"
def hello() :
print "Hi there python!"
hello();
#__END_OF_PYTHON__
which yields
$ perl -w x.ppr; ruby -w x.ppr; python x.ppr
Hi there perl!
Hi there ruby!
Hi there python!
at least with perl 5.6.0, ruby 1.6.4, and python 1.5.2.
All rather old.
An afternoon hack.
zSyUK3 zat vendian org
-
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.
|