Let me clarify my question a little.

I have a data file whose field order is fluid, but whose names are 
known, and whose records are delimited by returns, and whose fields 
are delimited by tabs.  The data file is stored in say @File.  But 
the first record contains the one word name of the field.  So I build 
an array - let's call it @rray = split (/\t/, $File[0]); , that 
contains all of the field names in the current order of the file.

Then when I want to build some output based on record $x of this 
file, I create say:

@Record = split (/\t/, $File[$x]);

Now I want to organize my logic by being able to call up say 
$Record[$address], or $Record[$phone_num], etc etc.

To do that I need $address to contain the position of the "address" 
field, gleaned from the current order of the fields contained in 
@rray.  So if @rray currently looks like qw (address phone_num fax 
note), I need:

  $address = 0;
  $phone_num = 1;
  $fax = 2;
  $note = 3;

So later I can say things like

   print "Record $x's Phone Number is:  $Record[$phone_num]\n";

But, when I run this to get there:

my $i = 0;
foreach (@rray) {
   $$_ = $i
   $i++;
   }

It fails.  So knowing my goals, would that alter your suggestions at 
all?  I could easily do something like

my $i = 0;
foreach (@rray) {
   $hash{$_} = $i
   $i++;
   }

But I'm not sure what no strict would do, nor what yardage an eval does me.

James

Reply via email to