What follows is a bit rambling, and not phrased as a question. Implementing this is rather involved, and I have too many questions to ask them all at once. I'm trying to take my existing code and generalize it, allow Myself to write Mac-specifc interfaces to it, and allow others to write code on (insert OS here), and not have to reinvent the wheel. Okay, so I've decided to turn the starmapping code into a module. This means (among other things) encapsulating the (rather hairy) data structure in a class. I think that it would be nice if I could do something like struct() in C (below). I'm looking for examples using Class::Struct, beyond those in the pod. Any help here anyone? I think my question is, how do I emulate this in Perl? We don't care about the different datatypes in C, there all scalars to Perl. An array is fine within a script, but what I really want to export from a module is not the array, but the structure of it. I also need a way to generate the structure on the fly based on the bytewise description for any particular catalog. If anyone really wants to help, I can provide a complete sample readme. Basically, the code needs to look for two lines: Byte-by-byte Description of file: catalog --------------------------------------------------------------------------- ----- where "catalog" is the name of the input catalog and WILL vary. then the code needs to parse the lines that look like this: 1- 8 A8 --- Ident Identifier starting by: where the first field indicated a range of bytes, the second is a datatype the third specifies what units the data are in, the forth is the NAME of the field, and the final is a comment. The code also needs to comment out lines like: Gl Gliese: CNS2, Veroeff. ARI Nr. 22 (1969) which are just extended comments for the previous record. This is pretty much the standard format for descriptions of NASA's ADC catalogs. Finally, when the code encounters a line of dashes: --------------------------------------------------------------------------- ----- What follows are Notes on the data, which could probably also be dealt with in some way (rolled into a pod(?)). At the moment, I think everything after the end of this second line of dashes is safely ignored. That may change. If it does, the code will also have to read the file summary. Larger catalogs are often borken up into managable chunks (all with the same format),and sometimes there's a "notes" file with extended info on the data, and a bytewise description in the readme. The reason for the above is that there are a multitude of input catalogs, and no common cross-reference for all of them. Ultimately I need to be able to get the $10 NASA ADC Vol. 1 CD-ROM, and just drop a readme on a script which will then generate the input structure for that catalog. I'm far too lazy to code structures for all those catalogs by hand. Beyond my ultimate desire are the Hipparcos and SkyMaster2000 (really, that's what NASA calls it) catalogs, (100,000 and 300,000 stars, respectively), which contain the most complete and accurate position data. Although NASA has code for creating subsets of the SkyMaster catalog, it doesn't do what I need (their use for the data is much different than mine), or run on my platform. Yes, this is a BIG project. I'm tackling it in little sections, believe me. My apologies for running on so --B /* This structure holds the data for one record of the Gliese-3 catalog. Each field is commented with the name of its field in the catalog data and its datatype in [square brackets]. Lengths of character arrays have had 1 added to them to allow room for the terminating '\0'. */ typedef struct stardata { char identifier[9]; /* Identifier of the star [A8]. */ char components[3]; /* Component of multi-star system [A2] */ char distrel; /* Reliability of the distance [A1] */ int ra_hours; /* Right ascension, hours component [I2] */ int ra_minutes; /* Right ascension, minutes component [I2] */ int ra_seconds; /* Right ascension, seconds component [I2] */ int dec_degrees; /* Declination, degrees incl. sign [A1 + I2] */ double dec_minutes; /* Declination, minutes component [F4.1] */ double propermotion; /* Total proper motion [F6.3] */ boolean pm_uncertain; /* TRUE if proper motion uncertain [A1] */ double pm_direction; /* Direction angle of proper motion [F5.1] */ double radialvelocity; /* Radial velocity [F6.1] */ char rv_remark[4]; /* Remarks on radial velocity [A3] */ char spectraltype[13]; /* Spectral type or color class [A12] */ char spectraltype_source; /* Selected source for spectral type [A1] */ double magnitude; /* Apparent magnitude [F6.2] */ char magnitude_origin; /* Origin of magnitude [A1] */ boolean joint_magnitude; /* TRUE if joint magnitude [A1] */ double b_v_magnitude; /* B-V color magnitude [F5.2] */ char b_v_origin; /* B-V magnitude origin [A1] */ boolean joint_b_v; /* TRUE if joint B-V magnitude [A1] */ double u_b_magnitude; /* U-B color magnitude [F5.2] */ char u_b_origin; /* U-B magnitude origin [A1] */ boolean joint_u_b; /* TRUE if joint U-B magnitude [A1] */ double r_i_magnitude; /* R-I color magnitude [F5.2] */ char r_i_origin; /* R-I magnitude origin [A1] */ boolean joint_r_i; /* TRUE if joint R-I magnitude [A1] */ double trig_parallax; /* Trigonometric parallax [F6.1] */ double trig_parallax_error; /* Error in trig. parallax [F5.1] */ double parallax; /* Resulting parallax [F6.1] */ double parallax_error; /* Parallax error [F5.1] */ char parallax_code; /* Code for parallax origin [A1] */ double absolute_magnitude; /* Absolute visual magnitude [F5.2] */ char abs_mag_notes[3]; /* Notes on visual magnitude [A2] */ char abs_mag_quality; /* Qualify of absolute magnitude [A1] */ int velocity_u; /* U component of velocity [I4] */ int velocity_v; /* V component of velocity [I4] */ int velocity_w; /* W component of velocity [I4] */ long hd_designation; /* HD Designation [I6] */ char dm_designation[13]; /* DM designation [A12] */ char giclas_number[10]; /* Giclas number [A9] */ char lhs_number[6]; /* LHS number [A5] */ char other_designation[6]; /* Other designations [A5] */ char remarks[70]; /* Additional information [A69] */ /* Data below here is calculated by the program, not read from the file */ double distance; /* Distance from Sol, equals 1/parallax */ double ra; /* Right ascension in decimal degrees */ double declination; /* Declination in decimal degrees */ double x; /* X position in earth-centric coords */ double y; /* Y position in earth-centric coords */ double z; /* Z position in earth-centric coords */ double xg; /* X position in galactic coords */ double yg; /* Y position in galactic coords */ double zg; /* Z position in galactic coords */ double ref_distance; /* Distance from reference point Xr, Yr, Zr */ double luminosity; /* Luminosity relative to Sol */ } stardata; /* This structure holds the current constraints about what to print */ typedef struct constraints { double ref_x; /* X position of reference point */ double ref_y; /* Y position of reference point */ double ref_z; /* Z position of reference point */ double mindist; /* Minimum distance from reference point */ double maxdist; /* Maximum distance from reference point */ double minlum; /* Minimum luminosity */ double maxlum; /* Maximum luminosity */ boolean allowbinaries; /* Allow binaries */ int outputstyle; /* SHORT, LONG, or XLONG */ char outputfilename[256]; /* Name of output file */ FILE *outputfile; /* Output file handle */ boolean interactive; /* Ask the user for information? */ } constraints; --B ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org