None of the examples you've given are valid for storing the results of a SQL select query - because none of them perform an SQL query but simply save a string in a variable (this is akin to writing "REALLY FAST CAR" on a piece of paper and then expecting that paper to win the Gran Prix.) As has been pointed out, you need to use a mechanism - e.g., the DB client directly, or the DBI module - which will perform that query. Here's an example of what that might look like:

# Silly example, but fits the spec my @languages = qx#echo "select Language from CountryLanguage where Co +untryCode='RUS'"|mysql -u username database_name#;

Another example, more in line with how it would usually be coded:

#!/usr/bin/perl -w use strict; use DBI; $|++; my %info = ( db => "database_name", user => "username", pass => "pAsSwOrD" ); my $dbh = DBI->connect("DBI:mysql:$info{db}", $info{user}, $info{pass} +); my $ref = $dbh->selectall_arrayref("select Language from CountryLangua +ge where CountryCode='RUS'") or die $DBI::errstr; my @languages = map { $_->[0] } @$ref; # Store the first element (' +Language') in array
Update: Saved the return as an array rather than printing it.

--
"Language shapes the way we think, and determines what we can think about."
-- B. L. Whorf

In reply to Re: Storing the results of a SQL select query that reutrns more than one row into a perl array by oko1
in thread Storing the results of a SQL select query that reutrns more than one row into a perl array by ajguitarmaniac

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.