Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > comments on JAPH?

Reply
Thread Tools

comments on JAPH?

 
 
Thomas Kratz
Guest
Posts: n/a
 
      11-17-2003
Hi,

below my first attempt for a JAPH. It's not that obfuscated, but I had
a tough time pressing it into 4 lines.

Comments anyone?

Thomas

--
open STDIN,"<&DATA";$=+=14;$%=50;while($_=(seek( #J~.> a>n~>>e~.......>r.
STDIN,$:*$=+$,+$%,0),getc)){/\./&&last;/\w| /&&( #.u.t.^..oP..r.>h>a~.e..
print,$_=$~);/~/&&++$:;/\^/&&--$:;/>/&&++$,;/</ #.>s^~h<t< ..~. ...c.^..
&&--$,;$:%=4;$,%=23;$~=$_;++$i==1?++$,:_;}__END__#.... >>e>r^..>l^...>k^..

 
Reply With Quote
 
 
 
 
LaDainian Tomlinson
Guest
Posts: n/a
 
      11-17-2003
"Thomas Kratz" wrote:
> Comments anyone?


Sure.

http://www.perlmonks.com/index.pl?no...uscated%20Code

You might get more response over there. This newsgroup is leans more toward
problem solving than Perl's silly side.

Brandan L.
--
$_=q$,197+,27S,137,08(),09-K,13,11%1332230!b#>:!+'t{$;srand$=;sub'x{$$$x+=po
p}$
qw=sub{$q++;$i[pop@a]=pop};unshift@a,x$_
for(map{reverse+split$,}/(\d*)!/g);&{$
qw}($+)while(s=,}?(\d{2})==x);$t=y*3012**d?reverse +split$i[@i]:die$_;@f=map$
i[$
_]?chr$i[$_]:chop$t,0..--$q+length;print+chr(int(rand(5+65)^ord)for@f,m$J A
PH$


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.541 / Virus Database: 335 - Release Date: 11/14/2003


 
Reply With Quote
 
 
 
 
LaDainian Tomlinson
Guest
Posts: n/a
 
      11-17-2003
"LaDainian Tomlinson" wrote:
> --
>

$_=q$,197+,27S,137,08(),09-K,13,11%1332230!b#>:!+'t{$;srand$=;sub'x{$$$x+=po
> p}$
> qw=sub{$q++;$i[pop@a]=pop};unshift@a,x$_
> for(map{reverse+split$,}/(\d*)!/g);&{$
>

qw}($+)while(s=,}?(\d{2})==x);$t=y*3012**d?reverse +split$i[@i]:die$_;@f=map$
> i[$
>

_]?chr$i[$_]:chop$t,0..--$q+length;print+chr(int(rand(5+65)^ord)for@f,m$J A
> PH$


I think it's time for a decent newsreader.

Brandan L.
--
bclennox AT eos DOT ncsu DOT edu


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.541 / Virus Database: 335 - Release Date: 11/14/2003


 
Reply With Quote
 
Michele Dondi
Guest
Posts: n/a
 
      11-18-2003
On Mon, 17 Nov 2003 14:21:04 +0100, Thomas Kratz
<(E-Mail Removed)> wrote:

>below my first attempt for a JAPH. It's not that obfuscated, but I had
>a tough time pressing it into 4 lines.
>
>Comments anyone?


My first comments, modulo the fact that I didn't even try (yet) to
understand what it does due to absymal lack of time, are:

(i) it doesn't work, for the following meaning of "doesn't work": it
prints "J" and then exits!

(ii) I see the following piece of code:

open STDIN,"<&DATA";# rest of line snipped

and that there's an __END__ token. Isn't it that you're maybe trying
to do something like '*ARGV=DATA'?


Michele
--
# This prints: Just another Perl hacker,
seek DATA,15,0 and print q... <DATA>;
__END__
 
Reply With Quote
 
Thomas Kratz
Guest
Posts: n/a
 
      11-18-2003
Michele Dondi wrote:

>
> My first comments, modulo the fact that I didn't even try (yet) to
> understand what it does due to absymal lack of time, are:
>
> (i) it doesn't work, for the following meaning of "doesn't work": it
> prints "J" and then exits!


That's because you are on Win* are you? It will work when you
change the 14 in the first line to 15.
To have this working on all platforms I'll have to find out how many bytes
are written for a newline. length("\n") will always return 1 for all
platforms.

>
> (ii) I see the following piece of code:
>
> open STDIN,"<&DATA";# rest of line snipped
>
> and that there's an __END__ token. Isn't it that you're maybe trying
> to do something like '*ARGV=DATA'?


More like '*STDIN=DATA'. It is just to be able to say getc instead of
getc(DATA).

Using ARGV would be an alternative (and the above problem would vanish).
I just found out that you can't paste the lines via STDIN (always tested
with a file ). The DATA filehandle seems to be missing. I have to look
that up.

Thomas

--
open STDIN,"<&DATA";$=+=14;$%=50;while($_=(seek( #J~.> a>n~>>e~.......>r.
STDIN,$:*$=+$,+$%,0),getc)){/\./&&last;/\w| /&&( #.u.t.^..oP..r.>h>a~.e..
print,$_=$~);/~/&&++$:;/\^/&&--$:;/>/&&++$,;/</ #.>s^~h<t< ..~. ...c.^..
&&--$,;$:%=4;$,%=23;$~=$_;++$i==1?++$,:_;}__END__#.... >>e>r^..>l^...>k^..

 
Reply With Quote
 
Anno Siegel
Guest
Posts: n/a
 
      11-21-2003
Thomas Kratz <(E-Mail Removed)> wrote in comp.lang.perl.misc:

> 2. I just realized (never thought about it before), that when you paste
> the code to the perl interpreter via STDIN, you won't get anything from
> the DATA filehandle. ...


Have you tried it?

Anno
 
Reply With Quote
 
Thomas Kratz
Guest
Posts: n/a
 
      11-21-2003
Anno Siegel wrote:

>>2. I just realized (never thought about it before), that when you paste
>>the code to the perl interpreter via STDIN, you won't get anything from
>>the DATA filehandle. ...

>
>
> Have you tried it?


Yes, although only with 5.6.0 and 5.8.0 under Win32. Does it behave
differently on other OSes?

I tried it with:

seek DATA,0,0;
print <DATA>;
__END__

prints '>><<' if pasted and

'>>seek DATA,0,0;
print '>>', <DATA>, '<<';
__END__
<<'

if run from a file

Thomas

--
open STDIN,"<&DATA";$=+=14;$%=50;while($_=(seek( #J~.> a>n~>>e~.......>r.
STDIN,$:*$=+$,+$%,0),getc)){/\./&&last;/\w| /&&( #.u.t.^..oP..r.>h>a~.e..
print,$_=$~);/~/&&++$:;/\^/&&--$:;/>/&&++$,;/</ #.>s^~h<t< ..~. ...c.^..
&&--$,;$:%=4;$,%=23;$~=$_;++$i==1?++$,:_;}__END__#.... >>e>r^..>l^...>k^..

 
Reply With Quote
 
Michele Dondi
Guest
Posts: n/a
 
      11-21-2003
On Thu, 20 Nov 2003 10:46:35 +0100, Thomas Kratz
<(E-Mail Removed)> wrote:

>Ok I'll try to be clearer.
>
>1. I am moving through the comment on the right side of the JAPH with
>'seek' and 'getc'. Therefore I need to know how many bytes the line
>endings consist of, to get the right offset. Just pulling everything into
>an array and parsing that would be easier.
>
>2. I just realized (never thought about it before), that when you paste
>the code to the perl interpreter via STDIN, you won't get anything from
>the DATA filehandle. I don't know if and - if yes - how I can get at the
>code when it comes in via STDIN.
>
>Better?


Definitely!

However, in Perl one seldom (say in "everiday's life quick scripts")
*really* needs getc() IMHO. And OTOH Perl's (more) common I/O
operators/functions manage line endings (and not only!) transparently
and platform-independently.

May you consider using something other than getc()? Also, why not
chomp()ing? Note: I deleted your code because I do not even want to be
tempted to try and see if these suggestions are compatible with its
logic! (not much spare time, sorry!)


Michele
--
# This prints: Just another Perl hacker,
seek DATA,15,0 and print q... <DATA>;
__END__
 
Reply With Quote
 
Ben Morrow
Guest
Posts: n/a
 
      11-21-2003

Thomas Kratz <(E-Mail Removed)> wrote:
> Anno Siegel wrote:
> > Have you tried it?

>
> I tried it with:
>
> seek DATA,0,0;
> print <DATA>;
> __END__
>
> prints '>><<' if pasted and


This is because pipes (and ttys, and whatever a command window behaves
as under Win32) are not seekable.

Ben

--
don't get my sympathy hanging out the 15th floor. you've changed the locks 3
times, he still comes reeling though the door, and soon he'll get to you, teach
you how to get to purest hell. you do it to yourself and that's what really
hurts is you do it to yourself just you, you and noone else * http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
Anno Siegel
Guest
Posts: n/a
 
      11-21-2003
Thomas Kratz <(E-Mail Removed)> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
>
> >>2. I just realized (never thought about it before), that when you paste
> >>the code to the perl interpreter via STDIN, you won't get anything from
> >>the DATA filehandle. ...

> >
> >
> > Have you tried it?

>
> Yes, although only with 5.6.0 and 5.8.0 under Win32. Does it behave
> differently on other OSes?
>
> I tried it with:
>
> seek DATA,0,0;
> print <DATA>;
> __END__


Uh, okay, apologies. I thought you were saying the DATA filehandle doesn't
work when STDIN is piped. Of course "seek DATA" must fail when the source
isn't seekable, for whatever reason.

Anno
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A program to replace all JS comments with JSP comments in jsp files tungchau81@yahoo.com Javascript 4 06-03-2006 02:00 PM
A program to replace all JS comments with JSP comments in jsp files tungchau81@yahoo.com Java 0 06-02-2006 06:35 AM
Comments format: comments extending over multi-line Monk C Programming 10 04-20-2005 05:09 PM
Firefox comments and questions? Noozer Firefox 3 04-21-2004 08:29 PM
Firefox 0.8 Comments Ol' Duffer Firefox 5 02-23-2004 01:54 AM



Advertisments