Sorry, some correction for my own example
old
my $data = $dbh->selectall_arrayref("SELECT field1, field2 FROM table");

new
my $data = $dbh->selectall_arrayref("SELECT field1, field2 FROM
table",{Slice=>{}});


On Thu, Jul 3, 2008 at 9:52 AM, David Romero <[EMAIL PROTECTED]> wrote:

> #!/usr/bin/perl
>
> use strict;
> use DBI;
>
> ##Conect to database
> my $dbh = DBI->connect('string','user','password') or die "Can't connect to
> database";
>
> #query
> my $data = $dbh->selectall_arrayref("SELECT field1, field2 FROM table");
>
> #open file for append >>,
> #  > for write
> #  >> for append
> #  Doc about this http://www.tizag.com/perlT/perlfileopen.php
> open(FILE,">>file.txt") or die "Can't open file: $!";
>
> #read each line of query results
> foreach my $line(@$data){
>   print FILE "$line->{field1}, $line->{field2}\n";
> }
>
> #close file
> close (FILE)
>
> #disconnect from database
> $dbh->disconnect;
>
>
> On Thu, Jul 3, 2008 at 2:46 AM, luke devon <[EMAIL PROTECTED]> wrote:
>
>> Hi ,
>>
>> I just tried to store some mysql-queried data in to a file. but it wont
>> work. Actually i wanted to do not just writing , it should be APPEND at each
>> time when that perl scripts runs.
>>
>> Can some body help me , if you all can provide me a sample or a example
>> would be a great help
>>
>> Many thanks
>> Luke
>>
>>
>> Send instant messages to your online friends
>> http://uk.messenger.yahoo.com
>
>
>
>
> --
> David Romero
> www.factufacil.com.mx
>
>


-- 
David Romero
www.factufacil.com.mx

Reply via email to