mhoang has asked for the wisdom of the Perl Monks concerning the following question:
Hi guys, I have wrote the small script to get data from 2 columns of sql server, I like to save data into a new array for processing, but I am not sure how to do it as each column has the long trailing of white space. When I assign to new array it breaks column to new row
$VAR1 = [ 'Wellbeing Office + ', 'Pending + ', 'Library + ', 'Pending + ', 'Y219 + ', 'InProgress + ', 'B201 + ', 'InProgress + ', 'B108 + ', 'InProgress + ', 'LAB1 + ', 'InProgress + ', 'C303 + ', 'InProgress + ' ];
#!/usr/bin/perl use strict; use warnings; use DBI; #establish the connection my $dbh = DBI->connect('dbi:ODBC:myDSN','username','userpassword') || die "Could not connect to database: $DBI::errstr"; #$dbh->{'LongTruncOk'} = 0; #$dbh->{'LongReadLen'} = 100; # sql query statement my $sql = qq/select location,CompletionStatus from ewNetworkFaults where Type like '%Audio Visual%' and CompletionStatus not like '%Completed%'/; # prepare the query my $sth = $dbh->prepare($sql); #execute the query $sth->execute() || die "SQL Error: $DBI::errstr\n"; + my @row; my @table = (); # retrieve the values returned from executing your SQL statement while (my @row = $sth->fetchrow_array()) { push @table,@row; #### This is the place I dont know how to save } use Data::Dumper; print Dumper(\@table);
|
|---|