Need help with eliminating newlines with Perl

Good morning,

I need some help with getting rid of newlines with the output from a MYSQL query and putting the information into the right format that I need.

Here is the script as it is today:

#!/usr/bin/perl

my $uda = system("/opt/incontrol/mysql/bin/mysql -u root -ppassword --skip-column-names instancename -e \"select blah, blah from blahblah;\"");

chomp($uda);

This is the output:

+-----------------+-----------------------------+
| blockTechPhone | 312-555-1212 |
| blockTechName | This guy |
| blockAdminName | hat guy |
| blockAdminPhone | 312-555-3232 |
| blockTechEmail | me@you.com |
| block_name | this is a test|
| subnet_nets | off |
| blockSecName | gfsdg |
+-----------------+-----------------------------+

Note that the output is 10 lines long. I want to get rid of the first and the last line, since those are just clutter from the MYSQL output. Get rid of the "+-----------------+-----------------------------+" lines. I want the rest to be merged into one line like this:

-c uda,set -Tipv4_subnet -a 10.1.10.0 -o Personal -u username -p password --uda Subnet/blockTechPhone="312-555-1212" --uda Subnet/blockTechName="This guy" --uda Subnet/blockAdminName="hat guy" --uda Subnet/blockAdminPhone="312-555-3232" --uda Subnet/blockTechEmail="me@you.com" --uda Subnet/block_name="this is a test" --uda Subnet/subnet_nets="off" --uda Subnet/blockSecName="gfsdg"

What is the best way to get the output into one line I am trying and to insert the additional words that I want like I am describing. I appreciate any assistance!

I am fairly new to Perl, but have a lot of shell scripting experience. I am trying to do this in Perl.

[highlight=perl]#! /usr/bin/perl -w
use strict;

my @x;
my $str = '-c uda,set -Tipv4_subnet -a 10.1.10.0 -o Personal -u username -p password --uda Subnet/blockTechPhone="312-555" --uda Subnet/blockTechName="This" --uda Subnet/blockAdminName="hat " --uda Subnet/blockAdminPhone="312-55" --uda Subnet/blockTechEmail="me@you.com" --uda Subnet/block_name="thi" --uda Subnet/subnet_nets="of" --uda Subnet/blockSecName="gf"';

open I, "< input";
for (<I>) {
if (/^[-+]+$/) {
next;
}
else {
chomp (@x = split /\|/);
$x[1] =~ s/^\s+|\s+$//g;
$x[2] =~ s/^\s+|\s+$//g;
$str =~ s/($x[1]=\").+?\"/$1$x[2]"/;
}
}
close I;

print "$str\n";[/highlight]

$ ./test.pl
-c uda,set -Tipv4_subnet -a 10.1.10.0 -o Personal -u username -p password --uda Subnet/blockTechPhone="312-555-1212" --uda Subnet/blockTechName="This guy" --uda Subnet/blockAdminName="hat guy" --uda Subnet/blockAdminPhone="312-555-3232" --uda Subnet/blockTechEmail="me@you.com" --uda Subnet/block_name="this is a test" --uda Subnet/subnet_nets="off" --uda Subnet/blockSecName="gfsdg"

You do realize that every time you run system() or backticks in perl, you waste an entire shell, right? To process all the shell code you're embedding in your perl? Meaning, your "perl" script is actually 99% shell code, using at least two external shells to do its job, and probably more if we saw the rest of your code? If you want to write perl, write perl; this isn't perl...

Furthermore, system() doesn't even work that way. system() doesn't return a string.

I think you can get much more usable output with --batch, which will cause it to not print the +------- fluff.