Inspired by Len's recent spiralling quine,
I have created a somersaulting camel.
camel.pl:
(Save all text between the ------ lines below)
------------------------------------------------------------------
''=~('(?{'.(
('`')| '%').('['^'-').
('`'|'!'). ('`'|',').'"'.('['
^'(').('[' ^'.'). ('`'|'"').('{'^'[').
'_\\{'.('['^('(')).( '['^'"').('['^('(')).(
'['^'/').('`'|"\%").( '`'|'-').'\\$^'.(('`')^
'/').'=~'.('{'^',') .('`'|')').('`'|'.').'?'.(
'`'^'#').('`'^ ',').('{'^'(').':'."'".("\`"|
'#').('`'|',') .('`'|'%').('`'|'!').('['^"\)").
"'".';'.(('[')^ '+').('['^')').('`'|')').('`'|'.').
('['^'/').'\\$' .'\\"'.('['^'#').'+'.('`'|'!').(('`')|
'"').('['^'('). '('.('^'^('`'|'/')).(':'&'=').'*('.('^'^
('`'|',')).'*' .'\\$|-\\$;)),\\$_,\\$/'.('`'|'&').("\`"|
'/').('['^')') .'\\@_;'.('['^'(').('`'|',').('`'|('%')).(
'`'|'%').('['^'+').('{'^'[').('^'^('`'|'/')).'\\}'.(('`')|
'/').('['^'+').('`'|'%').('`'|'.').'\\$%;'.('`'|'#').("\`"|
'(').('`'|'/').('['^'+').','.('['^'"').',!-~,#,,'.('['^'('
).',(.).?,\\$+,'.('`'|"'").('`'|'&').('`'|'/').('['^(')')).
'\\@~='.('`'|"'").('['^')').('`'|'%').('['^'+').'\\$|--,<'.
('^'^('`'|'.')).'>;\\@;='.('`'|'-').('`'|'!').('['^('+')).
'~~'.('['^')').('`'|'%').('['^'-').('`'|'%').('['^')' ).(
'['^'(').('`'|'%').','.('['^')').('`'|'%').('['^'-' ).(
'`'|'%').('['^')').('['^'(').('`'|('%')). '\\@~;(' .((
'\\')).'$;=\\$_%'.('^'^('`'|'-')).')|' .'|(--' .((
'\\') ).'$|,'.('`'|'-').('`'|"\!").( '['^'+' ).+
'\\{\\$_='.('['^')').('`'|'%' ).('['^ '-'
).("\`"| '%').('['^ ')').( ('[')^ ((
'('))). ('`'|'%' ).'\\' .'}\\' .+
'@~,\\' .'@;),_' .'\\' .'$;' .
"\&".( '^'^('`' |'/' )).+
'?\\@' .';:\\@~' .''. ('`'
|'&') .(('`')| '/') .''.
('['^ (')')). '\\' .'$'
.'%' .'..'. ('^' ^(((
'`') )|+ '/') ).+(
'^'^ ((( '`' ))|
'/' )). '"' .((
'}' )). ')' );(
$:) =(( '.' ))
^+ '~';$~ =(
(( '@')) )|
(( '('));$^ =(
')' )^(( '[')) ;(
$/) ="\`"| '.'; $_=
'('^ "\}";$,= '`' |'!'
;($\)= (')')^
"\}";$:= '.'^'~'
------------------------------------------------------------------
To run this program, save as camel.pl (say), then:
perl camel.pl
and watch the camel somersault across the screen.
camel.pl above was created with:
perl gencamel.pl >camel.pl
where gencamel.pl is:
use Acme::EyeDrops qw(sightly);
my $src = <<'END_SRC_STR';
sub _{system$^O=~Win?CLS:'clear';
print$"x+abs(18*(2*$|-$;)),$_,$/for@_;sleep 1}
open$%;
chop,y,!-~,#,,s,(.).?,$+,gfor@~=grep$|--,<0>;
@;=map~~reverse,reverse@~;
($;=$_%3)||(--$|,map{$_=reverse}@~,@;),
_$;&1?@;:@~for$%..11
END_SRC_STR
$src =~ tr/\n//d;
my $prog = sightly( { Regex => 1,
Compact => 1,
Shape => 'camel',
SourceString => $src } );
my @a = split(/\n/, $prog);
my $max = 0; length > $max and $max = length for @a;
$_ .= ' ' x ($max - length) for @a;
print " $_ \n" for @a;
It was quite a struggle to make this program small enough
to fit into a single camel shape, so any further golfing
improvements to gencamel.pl above are most welcome.
Re: Somersaulting camel
by eyepopslikeamosquito (Archbishop) on Jun 24, 2002 at 05:44 UTC
|
camel.pl:
(Save all text between the ------ lines below)
------------------------------------------------------------------
''=~('(?{'.(
('`')| '%').('['^'-').
('`'|'!'). ('`'|',').'"'.('['
^'(').('[' ^'.'). ('`'|'"').('{'^'[').
'_\\{'.('['^('(')).( '['^'"').('['^('(')).(
'['^'/').('`'|"\%").( '`'|'-').'\\$^'.(('`')^
'/').'=~'.('{'^',') .('`'|')').('`'|'.').'?'.(
'`'^'#').('`'^ ',').('{'^'(').':'."'".("\`"|
'#').('`'|',') .('`'|'%').('`'|'!').('['^"\)").
"'".';'.(('[')^ '+').('['^')').('`'|')').('`'|'.').
('['^'/').'\\$' .'\\"'.('['^'#').'+'.('`'|'!').(('`')|
'"').('['^'('). '(\\$=/'.('^'^('`'|'-')).'*('.('^'^('`'|
',')).'*\\$|-' .'\\$;)),\\$_,\\$/'.('`'|'&').('`'|'/').(
'['^')').'\\@' .'_;'.('['^'(').('`'|',').('`'|'%').("\`"|
'%').('['^'+').('{'^'[').('^'^('`'|'/')).'\\}'.('`'|'/').(
'['^'+').('`'|'%').('`'|'.').'\\$%;'.('`'|'#').('`'|"\(").(
'`'|'/').('['^'+').','.('['^'"').',!-~,#,,'.('['^'(').',('
.'.).?,\\$+,'.('`'|"'").('`'|'&').('`'|'/').('['^')').'\\@'
.'~='.('`'|"'").('['^')').('`'|'%').('['^'+').('\\$|--,(').
"'"."'".')'.('['^'#').('^'^('`'|'/')).(':'&'=').',<'.('^'^
('`'|'.')).'>;\\@;='.('`'|'-').('`'|'!').('['^('+')). '~'
.'~'.('['^')').('`'|'%').('['^'-').('`'|'%').("\["^ ')'
).('['^'(').('`'|'%').','.('['^')').('`'| ('%')).( '['
^'-').('`'|'%').('['^')').('['^"\(").( '`'|'%' ).+
'\\@' .'~;(\\$;=\\$_%'.('^'^('`'|'-' )).')|' .((
'|')).'(--\\$|,'.('`'|"\-").( '`'|'!' ).(
'['^'+') .'\\{\\$_' .'='.( ('[')^ ((
')'))). ('`'|'%' ).('[' ^'-'). +(
'`'|'%' ).("\["^ ')'). ('['^ (
'(')). ('`'|'%' ).(( '\\'
)).'}' .'\\@~,'. '\\' .'@'
.';)' .',_\\$' .';' .'&'
.('^' ^("\`"| '/') ).((
'?') ).'\\' .'@' .';'
.':' .(( '\\' )).+
'@~' .+( '`' |((
'&' ))) .+( '`'
|(( '/' ))) .+(
'[' ^(( ')' ))
). '\\$%' .+
(( '.')) .+
(( "\.")).( ((
'^' ))^( "\`"| ((
'/' )))).( '^'^ (((
'`') )|'/')). '"' .'}'
.')'); $:='.'
^'~';$~= '@'|'('
------------------------------------------------------------------
To run this program, save as camel.pl (say), then:
perl camel.pl
and watch the camel somersault across the screen.
camel.pl above was created with:
perl gencamel.pl >camel.pl
where gencamel.pl is:
use Acme::EyeDrops qw(sightly);
my $src = <<'END_SRC_STR';
sub _{system$^O=~Win?CLS:'clear';
print$"x+abs($=/3*(2*$|-$;)),$_,$/for@_;sleep 1}
open$%;
chop,y,!-~,#,,s,(.).?,$+,gfor@~=grep$|--,('')x18,<0>;
@;=map~~reverse,reverse@~;
($;=$_%3)||(--$|,map{$_=reverse}@~,@;),
_$;&1?@;:@~for$%..11
END_SRC_STR
$src =~ tr/\n//d;
my $prog = sightly( { Regex => 1,
Compact => 1,
Shape => 'camel',
SourceString => $src } );
my @a = split(/\n/, $prog);
my $max = 0; length > $max and $max = length for @a;
$_ .= ' ' x ($max - length) for @a;
print " $_ \n" for @a;
| [reply] [d/l] [select] |
Re: Somersaulting camel
by hacker (Priest) on Jun 23, 2002 at 16:35 UTC
|
Oddly enough, a quick google search returned the same code, from a gentleman named Andrew Savige. If you are Andrew, let us please see some of your other wonderful snippets.
If you are not Andrew, he has been contacted. Proper attribution of his hard work would have been in order. Plagarism is not a trait well-respected here. | [reply] |
|
It is not a plagiarist (oops, maybe I am a plagiarist by using ideas from Euridil's original camel code and from Len's clever use of clear).
If you look closely, however, you will notice that this post is different from the usenet one (a bug-free version of which can be found in Acme::EyeDrops documentation). The usenet post can generate many different camels, based on command-line switches. This one takes no command-line arguments, just tries to show a camel somersaulting across the screen. I just realised the second frame should show the camel jumping up in the air a bit, so I will try to fix that, so stay tuned for a "camel series". :) I can't fix it easily because I have run out of characters, need to do some golfing on it first.
/-\ndrew
| [reply] |
|
Because of a bit of confusion and the lack of a signiture this was red flagged. I contacted Andrew by email and he confirmed that this is his post. I hope this wasn't unjustly --'ed I had suggested leaving the post alone until we knew the facts, but a reply was posted already.
Sorry for any confusion. Welcome eyepopslikeamosquito you've got my ++ for an awesome obfu.
| [reply] |
Re: Somersaulting camel
by eyepopslikeamosquito (Archbishop) on Jun 25, 2002 at 03:05 UTC
|
Unlike BooK, I am not a specialist obfuscator. However, for cheap
thrills, I had a go at obfuscating the source program a little,
mainly by using some of the more obscure Perl built-in variables.
sub _{system$^O=~Win?CLS:'clear';
print$"x+abs($=/3*(2*$|-$-)),$_,$/for@_;sleep!$%}
open$%;
chop,y,!-~,#,,s,(.).?,$+,gfor@~=grep$|--,($|)x18,<0>;
@;=map~~reverse,reverse@~;
($-=--$_%3)||(--$|,map$_=reverse,@~,@;),
_!!$;&$-?@;:@~for$|..!!$;.$^F
Is the $|-- idiom well-known at Perl monks? Where is its behavior documented?
| [reply] [d/l] |
Re: Somersaulting camel
by eyepopslikeamosquito (Archbishop) on Jun 28, 2002 at 07:30 UTC
|
Update: Creating an EyeDrops-generated camel inevitably
degenerates into a golf crack-pipe smoking session on the
source text. So it has proved here. Golfing the original
source program has allowed me to support a new 'back-flip'
command-line argument as follows:
perl camel.pl camel forward somersaults as before
perl camel.pl b camel somersaults backwards
perl camel.pl please do a backward somersault
same thing
camel.pl:
(Save all text between the ------ lines below)
------------------------------------------------------------------
''=~('(?{'.(
('`')| '%').('['^'-').
('`'|'!'). ('`'|',').'"\\$~='
.('['^'+') .('`'| '/').('['^'+').'||'.
"'"."'".';'.('`'|'/' ).('['^'+').('`'|'%').
('`'|'.').('\\$%;').( '['^'"').(',!-~,#,,').(
'['^'(').',(.).,\\' .'$+,'.('`'|"'").('['^'(')
.',\\$~&&(\\$' .'_='.('['^')').('`'|('%')).(
'['^'-').('`'| '%').('['^')').('['^'(').(('`')|
'%').')'.("\`"| '&').('`'|'/').('['^"\)").'\\@~='.(
'`'|"'").("\["^ ')').('`'|'%').('['^'+').('\\$|--,(').
"'"."'".(')').( '['^'#').('^'^('`'|'/')).(':'&'=').',<'.
('^'^('`'|'.') ).'>;\\@;='.('`'|'-').('`'|'!').('['^'+')
.'~~'.('['^')' ).('`'|'%').('['^'-').('`'|'%').('['^')').
('['^'(').('`'|'%').','.('['^')').('`'|'%').('['^'-').('`'
|'%').('['^')').('['^'(').('`'|'%').'\\@~;'.('`'|'-').('`'|
'!').('['^'+').'\\{'.('['^'(').('['^'"').('['^'(').(('[')^
'/').('`'|'%').('`'|'-').'\\$^'.('`'^'/').'=~'.('{'^"\,").(
'`'|')').('`'|'.').'?'.('`'^'#').('`'^',').('{'^'(').(':').
"'".('`'|'#').('`'|',').('`'|'%').('`'|'!').('['^')')."'".
';(\\$-=\\$_%'.('^'^('`'|'-')).')||(--\\$|,'.('`'|'-' ).(
'`'|'!').('['^'+').'\\$_='.('['^')').('`'|'%').('[' ^((
'-'))).('`'|'%').('['^')').('['^'(').('`' |('%')). ','
.'\\@~,\\@;);'.('['^'+').('['^(')')).( '`'|')' ).(
"\`"| '.').('['^'/').'\\$\\"'.("\["^ ('#')). '('
.'\\$=/'.('^'^('`'|'-')).'*'. (('`')| '!'
).("\`"| '"').('['^ "\("). '\\$|' .+
('*').( '^'^('`' |',')) .'-\\' .+
'$-),'. '\\$_,'. '\\$' .'/'. (
('`')| ('&')).( '`'| '/')
.('['^ ')').'\\' .'$' .'-'
.'&'. (('^')^( '`'| '/')
).'?' .'\\@;' .':' .''.
'\\' .'@~;' .''. ('['
^'(' ).( '`'| ',')
.''. ((( '`' ))|
'%' ).( '`' |((
'%' ))) .+( '['
^(( '+' ))) .+
(( '!')). ((
(( '\\') ))
). '$%\\}'. ((
((( '\\' ))))) .+
'$' .'%..' .''. (((
'^') )^("\`"| '/' )).(
"\^"^( ('`')|
('/'))). '"})');
------------------------------------------------------------------
camel.pl above was created with:
perl gencamel.pl >camel.pl
where gencamel.pl is:
use Acme::EyeDrops qw(sightly);
my $src = <<'END_SRC_STR';
$~=pop||'';open$%;
y,!-~,#,,s,(.).,$+,gs,$~&&($_=reverse)for@~=grep$|--,('')x18,<0>;
@;=map~~reverse,reverse@~;
map{system$^O=~Win?CLS:'clear';
($-=$_%3)||(--$|,map$_=reverse,@~,@;);
print$"x($=/3*abs$|*2-$-),$_,$/for$-&1?@;:@~;
sleep!$%}$%..11
END_SRC_STR
$src =~ tr/\n//d;
my $prog = sightly( { Regex => 1,
Compact => 1,
Shape => 'camel',
SourceString => $src } );
my @a = split(/\n/, $prog);
my $max = 0; length > $max and $max = length for @a;
$_ .= ' ' x ($max - length) for @a;
print " $_ \n" for @a;
One more thing: camel.pl should still work if you add a
leading #!/usr/bin/perl -w line followed by a single blank
line; if you don't add the blank line, the camel may lose
one eye and somersault erratically.
| [reply] [d/l] [select] |
Re: Somersaulting camel
by eyepopslikeamosquito (Archbishop) on Jun 30, 2002 at 04:25 UTC
|
| [reply] |
Re: Somersaulting camel
by educated_foo (Vicar) on Jun 28, 2002 at 08:08 UTC
|
Is there a reason you use the unsightly-long name "system" instead of backticks ($^O=~Win?`CLS`:`clear`;)? Does it get "Eye-dropped" in less characters? If you're hard-pressed for characters, you could probably also get away with $^O=~W to test for Windows -- I can't think of another system with a capital 'W' in its name off-hand.
/s | [reply] [d/l] [select] |
|
Thanks for the suggestions! I will see if I can use them to squeeze more out of a solution that I thought was dry as a raisin. BTW, I am not a good golfer, miles behind the great Ton Hospel and Mtv Europe, that's why I keep prodding better golfers to help me. I had thought of using backticks but doubted it is portable to Windows 98 because I think you have to do it like this.
$^O=~Win?`CLS>&2`:`clear>&2`
and I don't think >&2 is portable to Win98. Still, who cares about that? ;) | [reply] [d/l] |
|
|