[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Parsing astronomical data in Perl



Chris Nandor, <pudge@pobox.com> wrote:

>It's up to you how you want to deal with it.  Right now it is something like:
>
>   $data = substr($line, $arr[0], $arr[1]-$arr[0]);
>
>You could do:
>
>   $data = substr($line, $arr[0]-1, $arr[1]-$arr[0]);
>
>Then where you signify the first character as 1, this line will subtract 1
>for you and make it the actual position 0, which is what you want.  Or you
>could mess with $[, but as perlfunc says, "don't do that".  :)

Hee, hee.... I'd earlier made a remark off-list to the effect that 
sometimes being a little anal-retentive prevents the shit from hitting 
the fan.  Reading the documentation doesn't hurt either.  Found this in 
perlvar:

-----
	$[	

The index of the first element in an array, and of the first character in 
a substring.  Default is 0, but you could set it to 1 to make Perl behave 
more like awk (or Fortran) when subscripting and when evaluating the 
index() and substr() functions.  (Mnemonic: [ begins subscripts.)

		As of Perl 5, assignment to "$[" is treated as a compiler directive, 
and cannot influence the behavior of any other file.  Its use is 
discouraged. 
-----
Especially that bit about behaving like FORTRAN, as I suspect my input 
data is output from FORTRAN (just a hunch).

Does anyone here want to see the code so far?  It's guaranteed 
non-functional at this point.  I'm implementing the math tomorrow. At 
this point, I also haven't done anything Mac-specific.

I'm thinking about how to format the output data.  The original program 
simply writes an ASCII file (with lots of nice formatting) with all the 
derived data.  However, the main purpose of the code is to derive 
cartesian coordinates for mapping in 3D.  "Why not," I'm thinking, "just 
finish the whole process in MacPerl, and output a graphic."  Actually, 
perhaps a graphical map in the form of a GIF, and a series of linked HTML 
files with the textual data.

# Fungal Parataxonomy                   Mycology Information (Mycoinfo)
# Webmaster, Staff Writer      **The World's First Mycology E-Journal**   
# <mailto:webmaster@mycoinfo.com>            <http://www.mycoinfo.com/> 
# "A couple of guys trying to do something great..."



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch