Now thats all fine writing to mixed data perfectly. However I have a small circle of code that wont behave itself. the simple database ( mixed.dat )just containes#!/usr/bin/perl print "Content-type: text/html\r\n\r\n"; ### Generate some numbers. $now = time(); $nill = time() + 50; $null = time() + 100; ### Then print to prove that worked print "<br><b>Line one from mixed.data = $now"; print "<br><b>Line two from mixed.data = $nill"; print "<br><b>Line three from mixed.data = $null"; ### Fine -- So now I make an array @scale = ($now,$nill,$null); ### And print to prove that works print "<br><b> Print Array = @scale"; ### Fine ### Then I overwrite mixed.data with $data_path = "data/mixed.data"; open(O, ">$data_path"); print O join("\n",@scale),"\n"; close(O);
Which results in mixed.data file being written as#!/usr/bin/perl print "Content-type: text/html\r\n\r\n"; ### First I read from database. $data_path = "data/mixed.data"; open(DAT, $data_path) || die("Could not open file!"); @rawdata=<DAT>; close(DAT); $now = $rawdata[0]; $nill = $rawdata[1]; $null = $rawdata[2]; ### Then print to prove that worked print "<br><b>Line one from mixed.data = $now"; print "<br><b>Line two from mixed.data = $nill"; print "<br><b>Line three from mixed.data = $null"; ### Fine so far-- So now I make an array @scale = ($now,$nill,$null); ### And print to prove that works print "<br><b> Print Array = @scale"; ### This results in browser. #----------------------------------- # Line one from mixed.data = FAST # Line two from mixed.data = FASTER # Line three from mixed.data = FASTEST # Printed from Array = FAST FASTER FASTEST #------------------------------------ ### Which is all very fine so far. ### Then I overwrite mixed.data with $data_path = "data/mixed.data"; open(O, ">$data_path"); print O join("\n",@scale),"\n"; close(O);
FASTER
FASTEST
With new line entries
The next time I run the script the data base will be written as
FAST
FASTER
jdporter added readmore tags
In reply to Vicious circle. by nasa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |