in reply to read the filename column
If you have more extensive processing than shown it may be worth considering using DBD::AnyData to wrap your file as a database.
use strict; use warnings; use DBI; my $dbh = DBI->connect ('dbi:AnyData(RaiseError=>1):'); $dbh->func ( 'Docs', 'Fixed', [<DATA>], { col_names => 'name,batch,file,size,date,status,owner', pattern => 'A16 A14 A26 A15 A25 A15 A9' }, 'ad_import' ); my $sql = 'SELECT name, batch, file FROM Docs order by name, batch'; my $sth = $dbh->prepare ($sql); $sth->execute (); while (my $row = $sth->fetchrow_hashref ()) { print "$row->{name} has '$row->{file}' and BatchID is $row->{batch +}\n"; } __DATA__
Given data as shown in the OP prints:
user1 has 'New Microsoft Word Docu' and BatchID is 1712 user1 has 'MIGRATE.DLL.698' and BatchID is 1715 user1 has 'test2.txt.542' and BatchID is 1718 user2 has 'amanda test 1 .doc.55' and BatchID is 1705 user2 has 'amanda test 1 .doc.544' and BatchID is 1706 user2 has 'amanda test 1 .doc.411' and BatchID is 1707 user3 has 'amanda test 2.doc.829' and BatchID is 1699 user3 has 'amanda test 2 .doc.610' and BatchID is 1701 user3 has 'amanda test 2 .doc.322' and BatchID is 1702
To use a file instead of data provided in __DATA__ replace [<DATA>] with the file name and 'ad_import' with 'ad_catalog'.
|
|---|