should be simple

H

hendedav

Gang,

I am trying to add single quotes to the value stored in a scalar,
but it will not let me. Is this breaking a rule of some sort? Please
let me know how I can get around this.

Thanks,
Dave


$temp = '1,2,3,4';
$vals = 'asdf';
$vals .= "'$temp',";
system "echo 'vals is: -$vals-' > /tmp/debug.txt";
 
H

hendedav

Gang,

     I am trying to add single quotes to the value stored in a scalar,
but it will not let me.  Is this breaking a rule of some sort?  Please
let me know how I can get around this.

Thanks,
Dave

$temp = '1,2,3,4';
$vals = 'asdf';
$vals .= "'$temp',";
system "echo 'vals is: -$vals-' > /tmp/debug.txt";

Never mind. The issue was with the system call using single quotes.
Issue resolved.
 
J

Jürgen Exner

[Please put the subject of your article into the Subject of your
article]
I am trying to add single quotes to the value stored in a scalar,
but it will not let me. Is this breaking a rule of some sort? Please
let me know how I can get around this.

$temp = '1,2,3,4';
$vals = 'asdf';
$vals .= "'$temp',";
system "echo 'vals is: -$vals-' > /tmp/debug.txt";

If you replace the last line with a simple
print $vals;
then you will notice that $vals does contain the desired single quotes
asdf'1,2,3,4',
which of course can be print()ed into a file directly, too.

It is your wierd system() call that messes things up for you because the
arguments are passed to your shell and who knows what your shell is
doing to those quotes. You may want to ask in NG that deals with your
command shell.

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,212
Messages
2,571,101
Members
47,696
Latest member
ecomwebsdesign

Latest Threads

Top