This is a discussion on Ways to write into file?? within the Perl forums, part of the Programming Talk category; Hi. I have a program which gets information into database and then the program writes it into a file. In ...
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Ways to write into file??
Hi.
I have a program which gets information into database and then the program writes it into a file. In the beginning the program checks $option1 and $option2 values. If $option1 == 0 then database query results could for example be something like this: Def: 2 Aut: 2 Min: 3 Vid: 1 And if the $option1 == 1 then results could be something like this: Def: 0 Aut: 0 Min: 4 // Def + Aut Vid: 4 // Min + Vid And $option2 works like $option1 but "titles" are different. Yit: Opt: Hre: Tre: So I run two sql-querys: $sqlQuery1 and $sql-query2 And I get results into tables: @SqlQueryResults @SqlQueryResults2 In this point I need some help. Now when I write query results into file I use Tie:File. It's working, but It is really messy. I would like to do this a little bit smarter: CODE tie @array, 'Tie::File', $file or die; if ($option1 == 0){ $array[0] = "Def: $SqlQueryResults[0]; $array[1] = "Aut: $SqlQueryResults[1]; $array[2] = "Min: $SqlQueryResults[2]; $array[3] = "Vid: $SqlQueryResults[3]; } elsif ($option1 == 1){ $array[0] = "Def: 0; $array[1] = "Aut: 0; $array[2] = "Min: $SqlQueryResults[0]; $array[3] = "Vid: $SqlQueryResults[1]; } else { print "Something is wrong\n"; } if ($option2 == 0){ $array[4] = "Yit: $SqlQueryResults2[0]; $array[5] = "Opt: $SqlQueryResults2[1]; $array[6] = "Hre: $SqlQueryResults2[2]; $array[7] = "Tre: $SqlQueryResults2[3]; } elsif ($option2 == 1){ $array[4] = "Yit: 0; $array[5] = "Opt: $SqlQueryResults2[0]; $array[6] = "Hre: 0; $array[7] = "Tre: $SqlQueryResults2[1]; } else { print "something is wrong\n"; } I know this is messy question, but ask more if you did't get it. Thanks. |
![]() |
| Thread Tools | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| testing of .net aplication | naga_sri | Testing Tutorials | 1 | 02-16-2007 03:27 AM |
| Tutorial on Silk Test | spriya279 | Testing Tutorials | 2 | 02-15-2007 07:31 PM |
| comp.lang.c Answers to Frequently Asked Questions (FAQ List) | Steve Summit | Tech FAQ | 0 | 06-01-2004 07:00 AM |
| Apple II Csa2 FAQs: Uploading & Downloading, Part 21/25 | rubywand@swbell.net | Tech FAQ | 0 | 05-04-2004 10:01 AM |
| Solaris x86 FAQ 2/2 | Dan Anderson | Tech FAQ | 0 | 04-27-2004 08:24 PM |