To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.off-topic.geekOpen lugnet.off-topic.geek in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Off-Topic / Geek / 3600
3599  |  3601
Subject: 
Re: Access a LEGO set DB with your phone!
Newsgroups: 
lugnet.off-topic.geek
Date: 
Mon, 18 Mar 2002 12:59:37 GMT
Viewed: 
261 times
  
In lugnet.off-topic.geek, Dan Boger writes:
In lugnet.off-topic.geek, Christopher L. Weeks wrote:

ahhh, you said the magic word (perl) :) If you could explain to me
exactly what you need, I'll give ya a script that will do it :)

Well, I've discarded the first part...the explanatory text up through the big
________.  Then I've read the rest of the file into an array where each item in
the array is one line.  So now I'm trying to split() the @array[items] by
column, something like this:

while ($i > 0) {
$set = $sets[$i];  #to assign each array item temporarily
@row = split (/\t/, $set)];  #to split each row into columns
$rowref = \@row  #attempting to create a reference scalar to rows
rows[$i] = $rowref;  #load the array of references
print"\ncheckpoint=2.$i\n$rows[$i]";  #trying to debug
$i++;
if (@sets[$i] == EOF || $i > 10000) {$i = -1};
}  #what's a better way to terminate the loop?

I'm obviously missing at least one critical issue.

Ideally, you'd explain what I'm doing wrong.  If you're going to supply an
alternate script, please don't make it a single line.  Perl junkies who love
those little indecipherable things aren't really helpful to me :-)

Since I discovered \t as a split() criterion I've been thinking of just loading
the whole thing as a single array and then just searching for the parts as
needed.  Is that a better way to do this?

Also, if I want to print the value of $i+1 in a loop based on incrementation of
$i, what do I do to represent that?  I was trying to figure that out yesterday,
but now that I'm thinking it about it freshly, it seems probable that I just
have to enclose it in backticks.  I don't actually know the rules for these
things, I'm just picking it up bit by bit.

you could use perl for that too,

I actually meant, "what should I be putting between the slashes to break it up
by field."  But after writing that, I discovered that \t means tab and that
works perfectly.  I'd been trying stuff like /  */ to represent more than one
space and stuff, but nothing worked for the whole data source.

Chris



Message has 1 Reply:
  Re: Access a LEGO set DB with your phone!
 
(...) first of all, you're running an open ended loop on the array, when you can just run through each element: foreach $set (@sets) { (...) that trailing ']' is a typo, right? I'm not running this, but I think that would be a syntax error... (...) (...) (23 years ago, 18-Mar-02, to lugnet.off-topic.geek)

Message is in Reply To:
  Re: Access a LEGO set DB with your phone!
 
(...) ahhh, you said the magic word (perl) :) If you could explain to me exactly what you need, I'll give ya a script that will do it :) (...) you could use perl for that too, except that why load the server more then you need to? get the list file, (...) (23 years ago, 18-Mar-02, to lugnet.off-topic.geek)

9 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR