print<<'E'x 2,"E\n";
print<<'E'x 2,"E\n";
E
The program must be fed to an unadorned Perl command 'perl' and
produce the output that would make 'perl' look like it has been
replaced with 'cat'. The null program is not a valid submission. (I
claim it first... :-)
$_='5O1v3v5y9)1b7u2q4x1i0e3u2"3S9n5w7s6&7o7h8k1l6k3u3/';s/(.)(.)/pack('C',ord($2)-$1)/eg;print;
--
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III |
| mer...@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/
[[ don't put a newline at the end ]]
$s='$s=%c%s%c;printf$s,39,$s,39;';printf$s,39,$s,39;
Unfortunately, it doesn't work even though it should; the output is
$s='$s=%c%sc;printf$s,39,$s,39;';printf$s,39,$s,39;
^ huh?
This happens with
$Header: perly.c,v 3.0.1.4 90/02/28 18:06:41 lwall Locked $
Patch level: 12
on a VAX8700 running ULTRIX.
Was this fixed in one of the more recent patches?
Adjust another curl attacker, [motto for a curling iron repair shop?]
--
ray...@math.berkeley.edu Maintainer of the csip Frequently Asked Questions
>Any one liners?
[[ don't put a newline at the end ]]
$s='$s=%c%s%c;printf$s,39,$s,39;';printf$s,39,$s,39;
Unfortunately, it doesn't work even though it should; the output is
$s='$s=%c%sc;printf$s,39,$s,39;';printf$s,39,$s,39;
^ huh?
the spot marked "huh?" has an ascii NUL here, run it through
cat -v or od -a to see it.
--Ed
With pl15, it puts out a null in place of that last percent, yup.
And, it looks pretty good in other terms, so I presume that's a bug.
Larry?
eval <<EOF;
print "Just another Perl hacker,"
EOF
#! /usr/bin/perl
system "cat $0";
--
To have a horror of the bourgeois (\( Tom Neff
is bourgeois. -- Jules Renard )\) tn...@bfmny0.UU.NET
An obvious abridgement is to delete all the E's:
print<<''x 2,"\n";
print<<''x 2,"\n";
Note the blank line at the end. A not-so-obvious improvement is that
the last semicolon is now optional. (For shame! You of all people
should have thought of this one, Randal!)
print<<''x 2,"\n"
print<<''x 2,"\n"
It's too bad you said the thing about cat. Otherwise
die<<''x 2."\n"
die<<''x 2."\n"
would qualifiy.
But, we can shorten the "\n" by two characters:
print<<''x 2,$/
print<<''x 2,$/
I haven't thought about one liners yet.
Larry
Depends on how recent you think patch 16 is. :-)
do_sprintf() was assuming that you wouldn't sprintf a string using itself
as the format, so it temporarily installed nulls in the string to
handle each % interpolation. Obviously a bad assumption...
Life's a beach. And then you dry.
Larry
Here is a one-liner. There may be shorter one-liners.
$_=q $_=qx;s/x/$"$_$"/;print ;s/x/$"$_$"/;print
Larry
I thought that was just for 'eval' (because of my original request).
Does that mean the book is off? :-)
$_="7072696e7420274a75737420616e6f74686572205065726c206861636b65722c27";
s/../pack('C',hex($&))/eg; eval;
syntax error in file - at line 1, next 2 tokens "syntax error"
Execution aborted due to compilation errors.
--
"We must never forget that if the war in Vietnam \ $ Tom Neff
is lost... the right of free speech will be X tn...@bfmny0.UU.NET
extinguished throughout the world." -- RN 10/27/65 $ \ uunet!bfmny0!tneff
That was for -e. eval has assumed a semicolon for a long time.
But it was easier to assume ; on all perl scripts than just on -e.
: Does that mean the book is off? :-)
It just means it doesn't have to end with a semicolon.
Now if we could just get it to reproduce itself...
Actually, I'd settle for it PROducing itself. I'm still slogging through
the tutorial...
If you folks out there have any examples you think are instructive for
novices, we'd sure like to see them. We can't promise to work them
in, but we're particularly looking for small scripts that illustrate
particular constructs constructively. You could get your name in print...
Say, Randal, do you think we should have an appendix of signature scripts?
Larry
This generates a syntax error because the ';' is appended to the end of the
resulting perl script, not to the end of the -e argument.
--
Piet* van Oostrum, Dept of Computer Science, Utrecht University,
Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands.
Telephone: +31-30-531806 Uucp: uunet!mcsun!ruuinf!piet
Telefax: +31-30-513791 Internet: pi...@cs.ruu.nl (*`Pete')
> #! /usr/bin/perl
> system "cat $0";
Let's take this one to the extreme. And we don't even need perl ;-(.
Just put the following line in the file junk, and make it executable.
#!/bin/cat junk
--
Tom Tkacik GM Research Labs, Warren MI 48090
uunet!edsews!rphroy!megatron!tkacik Work Ph: (313)986-1442
"Csh must go. This is non-negotiable!"
---- cut here for genrepro sh script ----
: genrepro - generate a self-reproducing perl program
echo junk >cur.prog
echo trash >cur.out
until cmp -s cur.prog cur.out
do
echo === not yet ===
cat cur.out
mv cur.out cur.prog
perl cur.prog 2>cur.out
done
mv cur.out cur.prog
echo === final version ===
cat cur.prog
---- end of genrepro sh script ----
---- cut here for cur.prog ----
syntax error in file cur.prog at line 1, next 2 tokens "syntax error"
Execution aborted due to compilation errors.
---- end of cur.prog ----
--
Algol 60 was an improvment on most | John Macdonald
of its successors - C.A.R. Hoare | jmm@eci386
How about:
$_=q print"\$_=q\t$_\t;eval" ;eval
The spaces are tabs, no newline at the end. There's also its more printable
cousin:
$_='print"\$_=\47$_\47;eval"';eval
But the 2 digit octal sequences seem kinda bogus.
George Phillips phil...@cs.ubc.ca {alberta,uw-beaver,uunet}!ubc-cs!phillips
""
[granjon] $ perl junk > junk.out
[granjon] $ ls -l junk*
-rw-r--r-- 1 jhpb arch 0 Mar 27 19:01 junk
-rw-r--r-- 1 jhpb arch 0 Mar 27 19:05 junk.out
Joe Buehler
exec 'cat', $0;
Nahhh ... too much of a cheat ... but it does fulfill Randal's requirement
that `"perl file" should behave exactly as "cat file"' :-)
Neil
E-Mail (UUCP) NWi...@axion.bt.co.uk (...!uunet!mcsun!axion.bt.co.uk!nwinton)
Organisation British Telecom Research Laboratories (RT3134)
Snail Mail 306 SSTF, BTRL, Martlesham Heath, IPSWICH IP5 7RE, UK
Telephone +44 473 646079 (or +44 473 643210)
*** This line intentionally left justified ***
Go back to my original article. I already DQ'ed that. Nice try. :-)
open(STDERR,">&STDOUT");warn "Just another Perl hacker,\n"