Displaying double quotes using Perl

Hi Guys,

I'm a Perl newbie and was wondering if there's a way of displaying
double quotes within double quotes.

I'm try to print the contents of the variable to a file by using the system function.

Here is an example of my code:
#==============================
$website = <STDIN>;
chomp $website;
$virtualhost_file = <STDIN>;
chomp $virtualhost_file;

$WebsiteConfFile = " \<VirtualHost *:80\>

ServerName $website
ServerAlias $website

DocumentRoot \"/home/$website\"
TransferLog /home/$website/logs/access_log
ErrorLog /home/$website/logs/error_log
";

system("echo \"$WebsiteConfFile\" > /etc/httpd/vhosts.d/$virtualhost_file");

#==============================

This is what it displays in the file:

#==============================
<VirtualHost *:80>

ServerName Test.com Web Based Testing Software
ServerAlias Test.com Web Based Testing Software

DocumentRoot /home/www.test.com
TransferLog /home/www.test.com/logs/access_log
ErrorLog /home/www.test.com/logs/error_log
#==============================

However if I use the print function to print to the console it prints out fine
see below:
#==============================
<VirtualHost *:80>

ServerName Test.com Web Based Testing Software
ServerAlias Test.com Web Based Testing Software

DocumentRoot "/home/www.test.com"
TransferLog /home/www.test.com/logs/access_log
ErrorLog /home/www.test.com/logs/error_log
#==============================

Maybe the system function is not the function to use in this instance.

Any ideas?

Many thanks

kbdesouza

Hi Guys,

I may have found a solution to problem. Rather then using the system command to echo the variable to the file. I decided to use a filehandle
to write to it

#===================================
$website = <STDIN>;
chomp $website;
$virtualhost_file = <STDIN>;
chomp $virtualhost_file;

$WebsiteConfFile = " \<VirtualHost *:80\>

ServerName $website
ServerAlias $website

DocumentRoot \"/home/$website\"
TransferLog /home/$website/logs/access_log
ErrorLog /home/$website/logs/error_log
";

$file = "/etc/httpd/vhosts.d/$virtualhost_file";

open(VIRFILE,">$file") or die "Cannot open files $!";
print VIRFILE $WebsiteConfFile;
close(VIRFILE);
#====================================

Cheers
Keith

what on earth are you trying to do?

it looks like a really hard way of going about it.