Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Beatnik (493)

Beatnik
  (email not shown publicly)
http://www.ldl48.org/

A 29 year old belgian who likes Mountain Dew, Girl Scout Cookies, Tim Hortons French Vanilla Flavoured Cappucinno, Belgian beer, Belgian chocolate, Belgian women, Magners Cider, chocolate chipped cookies and Perl. Likes snowboarding, snorkling, sailing and silence. Bach can really cheer him up! He still misses his dog.

Project Daddy of Spine [sf.net], a mod_perl based CMS.

In his superhero time (8.30 AM to 5.30 PM), he works on world peace.

Journal of Beatnik (493)

Monday January 12, 2004
06:52 PM

Parrot #2

[ #16788 ]
Another try at Parrot code...

#!/usr/local/bin/parrot

open P0, "data.txt","<" #Open file for reading and store filehandle in P0
readline S0, P0 #Assume all values are on same line.. read from filehandle P0 into S0
close P0 #Close filehandle P0
index I0, S0, " " #Find first occurance of space, as in find first word and store position in I0
substr S1, S0, 0, I0 #Extract first word from S0 into S1
length I1, S0 #Store length of line S0 into I1
REDO: #Redo until a certain point is reached..
length I2, S1 #Store length of word S1 into I2
sub I1, I2 #Subtract word length I2 from string length I1
substr S0, S0, I0, I1 #Remove substr from S0 starting from pos I0 ending at I1
substr S0, S0, 1, I1 #Remove the space at front
save I2 #Push word length on stack
print I2 #Print the length of the string
print "\n" #Add a newline
index I0, S0, " " #Find first occurance of space, as in find first word and store position in I0
substr S1, S0, 0, I0 #Extract first word from S0 into S1
length I1, S0 #Store length of line S0 into I1
ne I1, 0, REDO
end


This will read a line from a text file and push the word lengths on the user stack. I will, somehow, base a beatnik interpreter on this bit.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.