Here's my problem:
 
I am writing a program that opens one file  (pricedata.csv)  as input, does 
some processing, and opens a new file  (PriceDataRfrmtd1.txt)  for ouput.  
Subsequently I close both files.  So far so good. Now, within the same program, 
I 
attempt to re-open the previous  output (i.e. PriceDataRfrmtd1.txt) as input 
and perform some processing and I  begin to run into some problems. More 
specifically, here's a segment of my  code:
 
 
while(<INPUT>) {
 
  $TheRec = $_;
chomp($TheRec);
 
  @Row =  split(/\s+/, $TheRec);
 
  print "[EMAIL PROTECTED] = @Row\n";
 
  $Date = $Row[0];
$AdjOpen = $Row[2];
$AdjClose =  $Row[4];


print "\n\$Date = $Date\n";
print "\n\$AdjOpen =  $AdjOpen\n";
print "\n\$AdjClose =  $AdjClose\n";

exit;


} # End of while(<INPUT>)
 
 
The first input record from the file "PriceDataRfrmtd1." is as  follows:
 
02-01-93  43.97  35.29  44.25  35.51 1.246
 
The List @Row should contain 6 entries.  
 
$Date = $Row[0] should equal 02-01-93.

$AdjOpen = $Row[2] should equal 35.29.

$AdjClose = $Row[4] should equal 35.51.
 
However, when I run the program I am getting the following results:
 
@Row appears to contain only one entry....namely....the entire input  record:
 
02-01-93   43.97   35.29   44.25   35.51  1.246
 
$Date = $Row[0] equals this first and only entry:
 
02-01-93   43.97   35.29   44.25   35.51  1.246
 
while both $AdjOpen = $Row[2]  and  $AdjClose = $Row[4] equal  "".....that 
is...they are empty.
 
Apparently, the statement "@Row =  split(/\s+/, $TheRec);" is not  
recognizing the blanks between the fields in the input record.  Are they  
something 
other than blanks?
 
Originally, I wrote two separate programs to perform this function.   That is 
I wrote program one to read in input file "pricedata.txt" and write it  out 
to "PriceDataRfrmtd.txt". Next I wrote a second program to read  
"PriceDataRfrmtd.txt" as input, do some processing and write it out to a  new 
reformatted 
output file.  However, when I decided to combine  both programs, I began to run 
into this probelm. I am running this Perl  program in DOS under the Windows XP 
operating system.  Do you know what the  problem is?
 
Thanks,
 
Frank





Reply via email to