Perl array printing on multiple lines but should be one lineCreate ArrayList from arrayHow do I check if an array includes an object in JavaScript?How to append something to an array?Deleting an element from an array in PHPWhat's the simplest way to print a Java array?How do I empty an array in JavaScript?Loop through an array in JavaScriptHow to check if an object is an array?How do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?

What could cause the sea level to massively decrease?

Can a landlord force all residents to use the landlord's in-house debit card accounts?

Conditions for Roots of a quadratic equation at infinity

Distinguish the explanations of Galadriel's test in LotR

Who buys a weak currency?

Reference request: quantifier elimination test

Was it ever illegal to name a pig "Napoleon" in France?

Why different specifications for telescopes and binoculars?

When do flights get cancelled due to fog?

How to convert diagonal matrix to rectangular matrix

What was the profession 芸者 (female entertainer) called in Russia?

Users forgetting to regenerate PDF before sending it

US citizen traveling with Peruvian passport

Publishing papers seem natural to many, while I find it really hard to think novel stuff to pursue till publication. How to cope up with this?

Did right-wing politician Franz Josef Strauss ever explain why he gave a 3 billion loan to East Germany in 1983?

What exactly is a "murder hobo"?

Estimates on number of topologies on a finite set

What would +1/+2/+3 items be called in game?

Did depressed people far more accurately estimate how many monsters they killed in a video game?

Four ships at the ocean with the same distance

Can the word "desk" be used as a verb?

Quoridor rules when faced the opponent

Why is a mixture of two normally distributed variables only bimodal if their means differ by at least two times the common standard deviation?

I make billions (#6)



Perl array printing on multiple lines but should be one line


Create ArrayList from arrayHow do I check if an array includes an object in JavaScript?How to append something to an array?Deleting an element from an array in PHPWhat's the simplest way to print a Java array?How do I empty an array in JavaScript?Loop through an array in JavaScriptHow to check if an object is an array?How do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















UPDATE: Added Data::Dumper as requested and output is as follows:



$VAR1 = [
[
'99'
],
[
'SELECT COUNT (1) FROM all_tables;'
]
];
values = 99
values = SELECT COUNT (1) FROM all_tables;


Simply put, I am expecting 1 row with two elements but I get two rows with 1 element using perl functions that produce expected results in other scripts. I cannot seem to figure out why I am getting these results.



I have added the two functions in the code below to keep it all as one script for testing but they are stored in a shared 'utilities' perl script as they are used throughout our entire code base. I have also included below the table and data used to reproduce the issue. I am using Perl v5.10.1 and Oracle 11.2.0.



This is the result when the script is run:



values = 99
values = SELECT COUNT (1) FROM all_tables;


This is the script:



#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;

my $schema = "ULVR_CDM";

my $mkt_query = "SELECT sql_id, sql_statement FROM cdm_ref_qbr_sql WHERE sql_type = 'MARKET' AND status = 'A' and sql_id=99;";
my @slqry_result = get_query_result_multiple_rows($mkt_query,$schema);
print Dumper @slqry_result;
foreach my $rows (@slqry_result)
print "values = @$rowsn";


exit 0;

sub get_query_result_multiple_rows
# Query returns multiple rows. Each row is split into a list where column separator is '

sub sql_query
my ($query, $user) = @_;
my $query_cmd = "/opt/u01/app/oracle/product/11.2.0/client_1/bin/sqlplus -s ULVR_CDM_USER/xxxxxxx\@d2ulvr <<EOF
set echo off
set newpage 0
set space 0
set pagesize 0
set feedback off
set heading off
set trimspool on
set tab off
set colsep


Code to create table and populate:



CREATE TABLE CDM_REF_QBR_SQL
( SQL_ID NUMBER,
SQL_TYPE VARCHAR2(10),
SQL_STATEMENT VARCHAR2(4000)
);

INSERT INTO CDM_REF_QBR_SQL (SQL_ID, SQL_TYPE, SQL_STATEMENT)
VALUES ( 99,'MARKET', 'SELECT COUNT (1) FROM all_tables;');
COMMIT;









share|improve this question
























  • what does use Data::Dumper; print Dumper @slqry_result' show?

    – jhnc
    Mar 26 at 1:18






  • 6





    Why not use DBI to run your query? It'd be a lot simpler than trying to parse the output of a program.

    – Shawn
    Mar 26 at 1:47











  • @Shawn - while DBI does not explain the issue presented, it does however solve the problem so thank you for redirecting me.

    – LGonyer
    Mar 26 at 12:40






  • 1





    @LGonyer: Please don't put useful new information like that in a comment where it is almost impossible to read. Instead, please edit your question and add it there.

    – Dave Cross
    Mar 26 at 13:34






  • 1





    That doesn't match anything that would be produced by querying the table from the end of your question. I'm expecting @slqry_results after you assign from get_query_result_multiple_rows in your code

    – jhnc
    Mar 26 at 15:15

















0















UPDATE: Added Data::Dumper as requested and output is as follows:



$VAR1 = [
[
'99'
],
[
'SELECT COUNT (1) FROM all_tables;'
]
];
values = 99
values = SELECT COUNT (1) FROM all_tables;


Simply put, I am expecting 1 row with two elements but I get two rows with 1 element using perl functions that produce expected results in other scripts. I cannot seem to figure out why I am getting these results.



I have added the two functions in the code below to keep it all as one script for testing but they are stored in a shared 'utilities' perl script as they are used throughout our entire code base. I have also included below the table and data used to reproduce the issue. I am using Perl v5.10.1 and Oracle 11.2.0.



This is the result when the script is run:



values = 99
values = SELECT COUNT (1) FROM all_tables;


This is the script:



#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;

my $schema = "ULVR_CDM";

my $mkt_query = "SELECT sql_id, sql_statement FROM cdm_ref_qbr_sql WHERE sql_type = 'MARKET' AND status = 'A' and sql_id=99;";
my @slqry_result = get_query_result_multiple_rows($mkt_query,$schema);
print Dumper @slqry_result;
foreach my $rows (@slqry_result)
print "values = @$rowsn";


exit 0;

sub get_query_result_multiple_rows
# Query returns multiple rows. Each row is split into a list where column separator is '

sub sql_query
my ($query, $user) = @_;
my $query_cmd = "/opt/u01/app/oracle/product/11.2.0/client_1/bin/sqlplus -s ULVR_CDM_USER/xxxxxxx\@d2ulvr <<EOF
set echo off
set newpage 0
set space 0
set pagesize 0
set feedback off
set heading off
set trimspool on
set tab off
set colsep


Code to create table and populate:



CREATE TABLE CDM_REF_QBR_SQL
( SQL_ID NUMBER,
SQL_TYPE VARCHAR2(10),
SQL_STATEMENT VARCHAR2(4000)
);

INSERT INTO CDM_REF_QBR_SQL (SQL_ID, SQL_TYPE, SQL_STATEMENT)
VALUES ( 99,'MARKET', 'SELECT COUNT (1) FROM all_tables;');
COMMIT;









share|improve this question
























  • what does use Data::Dumper; print Dumper @slqry_result' show?

    – jhnc
    Mar 26 at 1:18






  • 6





    Why not use DBI to run your query? It'd be a lot simpler than trying to parse the output of a program.

    – Shawn
    Mar 26 at 1:47











  • @Shawn - while DBI does not explain the issue presented, it does however solve the problem so thank you for redirecting me.

    – LGonyer
    Mar 26 at 12:40






  • 1





    @LGonyer: Please don't put useful new information like that in a comment where it is almost impossible to read. Instead, please edit your question and add it there.

    – Dave Cross
    Mar 26 at 13:34






  • 1





    That doesn't match anything that would be produced by querying the table from the end of your question. I'm expecting @slqry_results after you assign from get_query_result_multiple_rows in your code

    – jhnc
    Mar 26 at 15:15













0












0








0








UPDATE: Added Data::Dumper as requested and output is as follows:



$VAR1 = [
[
'99'
],
[
'SELECT COUNT (1) FROM all_tables;'
]
];
values = 99
values = SELECT COUNT (1) FROM all_tables;


Simply put, I am expecting 1 row with two elements but I get two rows with 1 element using perl functions that produce expected results in other scripts. I cannot seem to figure out why I am getting these results.



I have added the two functions in the code below to keep it all as one script for testing but they are stored in a shared 'utilities' perl script as they are used throughout our entire code base. I have also included below the table and data used to reproduce the issue. I am using Perl v5.10.1 and Oracle 11.2.0.



This is the result when the script is run:



values = 99
values = SELECT COUNT (1) FROM all_tables;


This is the script:



#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;

my $schema = "ULVR_CDM";

my $mkt_query = "SELECT sql_id, sql_statement FROM cdm_ref_qbr_sql WHERE sql_type = 'MARKET' AND status = 'A' and sql_id=99;";
my @slqry_result = get_query_result_multiple_rows($mkt_query,$schema);
print Dumper @slqry_result;
foreach my $rows (@slqry_result)
print "values = @$rowsn";


exit 0;

sub get_query_result_multiple_rows
# Query returns multiple rows. Each row is split into a list where column separator is '

sub sql_query
my ($query, $user) = @_;
my $query_cmd = "/opt/u01/app/oracle/product/11.2.0/client_1/bin/sqlplus -s ULVR_CDM_USER/xxxxxxx\@d2ulvr <<EOF
set echo off
set newpage 0
set space 0
set pagesize 0
set feedback off
set heading off
set trimspool on
set tab off
set colsep


Code to create table and populate:



CREATE TABLE CDM_REF_QBR_SQL
( SQL_ID NUMBER,
SQL_TYPE VARCHAR2(10),
SQL_STATEMENT VARCHAR2(4000)
);

INSERT INTO CDM_REF_QBR_SQL (SQL_ID, SQL_TYPE, SQL_STATEMENT)
VALUES ( 99,'MARKET', 'SELECT COUNT (1) FROM all_tables;');
COMMIT;









share|improve this question
















UPDATE: Added Data::Dumper as requested and output is as follows:



$VAR1 = [
[
'99'
],
[
'SELECT COUNT (1) FROM all_tables;'
]
];
values = 99
values = SELECT COUNT (1) FROM all_tables;


Simply put, I am expecting 1 row with two elements but I get two rows with 1 element using perl functions that produce expected results in other scripts. I cannot seem to figure out why I am getting these results.



I have added the two functions in the code below to keep it all as one script for testing but they are stored in a shared 'utilities' perl script as they are used throughout our entire code base. I have also included below the table and data used to reproduce the issue. I am using Perl v5.10.1 and Oracle 11.2.0.



This is the result when the script is run:



values = 99
values = SELECT COUNT (1) FROM all_tables;


This is the script:



#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;

my $schema = "ULVR_CDM";

my $mkt_query = "SELECT sql_id, sql_statement FROM cdm_ref_qbr_sql WHERE sql_type = 'MARKET' AND status = 'A' and sql_id=99;";
my @slqry_result = get_query_result_multiple_rows($mkt_query,$schema);
print Dumper @slqry_result;
foreach my $rows (@slqry_result)
print "values = @$rowsn";


exit 0;

sub get_query_result_multiple_rows
# Query returns multiple rows. Each row is split into a list where column separator is '

sub sql_query
my ($query, $user) = @_;
my $query_cmd = "/opt/u01/app/oracle/product/11.2.0/client_1/bin/sqlplus -s ULVR_CDM_USER/xxxxxxx\@d2ulvr <<EOF
set echo off
set newpage 0
set space 0
set pagesize 0
set feedback off
set heading off
set trimspool on
set tab off
set colsep


Code to create table and populate:



CREATE TABLE CDM_REF_QBR_SQL
( SQL_ID NUMBER,
SQL_TYPE VARCHAR2(10),
SQL_STATEMENT VARCHAR2(4000)
);

INSERT INTO CDM_REF_QBR_SQL (SQL_ID, SQL_TYPE, SQL_STATEMENT)
VALUES ( 99,'MARKET', 'SELECT COUNT (1) FROM all_tables;');
COMMIT;






arrays perl output






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 16:02







LGonyer

















asked Mar 25 at 23:22









LGonyerLGonyer

215 bronze badges




215 bronze badges












  • what does use Data::Dumper; print Dumper @slqry_result' show?

    – jhnc
    Mar 26 at 1:18






  • 6





    Why not use DBI to run your query? It'd be a lot simpler than trying to parse the output of a program.

    – Shawn
    Mar 26 at 1:47











  • @Shawn - while DBI does not explain the issue presented, it does however solve the problem so thank you for redirecting me.

    – LGonyer
    Mar 26 at 12:40






  • 1





    @LGonyer: Please don't put useful new information like that in a comment where it is almost impossible to read. Instead, please edit your question and add it there.

    – Dave Cross
    Mar 26 at 13:34






  • 1





    That doesn't match anything that would be produced by querying the table from the end of your question. I'm expecting @slqry_results after you assign from get_query_result_multiple_rows in your code

    – jhnc
    Mar 26 at 15:15

















  • what does use Data::Dumper; print Dumper @slqry_result' show?

    – jhnc
    Mar 26 at 1:18






  • 6





    Why not use DBI to run your query? It'd be a lot simpler than trying to parse the output of a program.

    – Shawn
    Mar 26 at 1:47











  • @Shawn - while DBI does not explain the issue presented, it does however solve the problem so thank you for redirecting me.

    – LGonyer
    Mar 26 at 12:40






  • 1





    @LGonyer: Please don't put useful new information like that in a comment where it is almost impossible to read. Instead, please edit your question and add it there.

    – Dave Cross
    Mar 26 at 13:34






  • 1





    That doesn't match anything that would be produced by querying the table from the end of your question. I'm expecting @slqry_results after you assign from get_query_result_multiple_rows in your code

    – jhnc
    Mar 26 at 15:15
















what does use Data::Dumper; print Dumper @slqry_result' show?

– jhnc
Mar 26 at 1:18





what does use Data::Dumper; print Dumper @slqry_result' show?

– jhnc
Mar 26 at 1:18




6




6





Why not use DBI to run your query? It'd be a lot simpler than trying to parse the output of a program.

– Shawn
Mar 26 at 1:47





Why not use DBI to run your query? It'd be a lot simpler than trying to parse the output of a program.

– Shawn
Mar 26 at 1:47













@Shawn - while DBI does not explain the issue presented, it does however solve the problem so thank you for redirecting me.

– LGonyer
Mar 26 at 12:40





@Shawn - while DBI does not explain the issue presented, it does however solve the problem so thank you for redirecting me.

– LGonyer
Mar 26 at 12:40




1




1





@LGonyer: Please don't put useful new information like that in a comment where it is almost impossible to read. Instead, please edit your question and add it there.

– Dave Cross
Mar 26 at 13:34





@LGonyer: Please don't put useful new information like that in a comment where it is almost impossible to read. Instead, please edit your question and add it there.

– Dave Cross
Mar 26 at 13:34




1




1





That doesn't match anything that would be produced by querying the table from the end of your question. I'm expecting @slqry_results after you assign from get_query_result_multiple_rows in your code

– jhnc
Mar 26 at 15:15





That doesn't match anything that would be produced by querying the table from the end of your question. I'm expecting @slqry_results after you assign from get_query_result_multiple_rows in your code

– jhnc
Mar 26 at 15:15












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347788%2fperl-array-printing-on-multiple-lines-but-should-be-one-line%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347788%2fperl-array-printing-on-multiple-lines-but-should-be-one-line%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript