Untouchable Monks. Greetings.

From the following code
while ($odbc->FetchRow()) { my @hydra_data = $odbc->Data; for my $data (@hydra_data) { if ($data) { #print $data->{source_mail}; my @db_info = split (/\s/, $data); printf "%s ",$db_info[0]; } } print "\n-----------------------------------------\n"; }
The data retrieved by $odbc->FetchRow() which is stored in @hydra_data doen’t seem to have spaces between the individual fields, so the my @db_info = split (/\s/, $data); can’t split the retrieved data into individual fields!In other words the line  printf "%s ",$db_info[0]; would print the data with no spaces between them. i.e. if the data was AAA, BBB, CCC the output is AAABBBCCC.

My question is; how can I split the data so I can get to the individual fields?

Is there something wrong with the script .i.e, Have I messed it up again somewhere? Because I thought I was doing the correct things there! Anyway, Thanks for your help and advise.

Here is the full code just in case;
#! c:/perl/bin/perl.exe -slw # $|++; require 5.008; use strict; use warnings 'all'; use Win32; use Win32::ODBC; my $dsn = "Hydra_FE"; my $qry = "qrywinbuild"; my $db = new Win32::ODBC($dsn) or die "\nError=>\t$^E : $!\n"; if (! $db) { print "\nError: $^E, ". Win32::ODBC::Error()."\n"; exit 1; } else { if ($db->sql("SELECT source_mail,hostname,machine_name FROM $qry W +HERE Business_Unit_name = '$ARGV[0]'")) { print "Error " . $db->Error() . "\n"; } else { print "\n\nObtaining $qry data from $dsn database\n\n"; while ($db->FetchRow()) { my @hydra_data = $db->Data; for my $data (@hydra_data) { if ($data) { my @db_info = split (/ /, $data); printf "%s ",$db_info[0]; } } print "\n-----------------------------------------\n"; } } } $db->Close();
Thanks guys

Blackadder

In reply to $ODBC->FetchRow() question? by blackadder

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.