dopefries
04-16-2007, 04:59 PM
Hi everyone,
I'm having trouble retrieving data from a database using perl and need some help. At the
moment I am using a flat file which is tagged on the end of the perl script ie.
...
my %routes;
chomp(my @lines = <DATA>);
foreach (@lines){
my ($from, $to, $w, $m) = split /:/;
$routes{$from} ||= {};
$routes{$from}{$to} = { weight => $w,
method => $m };
}
...
__DATA__;
Aberystwyth:Birmingham:92:train
Aberystwyth:Gloucester:86:train
Barrow:Sunderland:91:train
Barrow:Blackpool:22:bus
This is not how I want to do it. I now have a MySQL table with the data in but I'm not sure
how to get the data out in the same format. The fields in my table (routes) are
id, source, destination, transport, distance, date
Please help me out here.
Thanks
Emma x
I'm having trouble retrieving data from a database using perl and need some help. At the
moment I am using a flat file which is tagged on the end of the perl script ie.
...
my %routes;
chomp(my @lines = <DATA>);
foreach (@lines){
my ($from, $to, $w, $m) = split /:/;
$routes{$from} ||= {};
$routes{$from}{$to} = { weight => $w,
method => $m };
}
...
__DATA__;
Aberystwyth:Birmingham:92:train
Aberystwyth:Gloucester:86:train
Barrow:Sunderland:91:train
Barrow:Blackpool:22:bus
This is not how I want to do it. I now have a MySQL table with the data in but I'm not sure
how to get the data out in the same format. The fields in my table (routes) are
id, source, destination, transport, distance, date
Please help me out here.
Thanks
Emma x