Exforsys

Free Training

Ways to write into file??

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 ...

Go Back   Exforsys > Programming Talk > Perl

Exforsys.com

  #1 (permalink)  
Old 02-22-2007, 07:20 PM
Junior Member
 
Join Date: Feb 2007
Posts: 22
JohnDoe is on a distinguished road
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

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


All times are GMT -4. The time now is 04:04 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0
Copyright 2004 - 2009 Exforsys Inc. All rights reserved.