http://www.perlmonks.org?node_id=1047604

inktuma has asked for the wisdom of the Perl Monks concerning the following question:

Im trying to send a command through the telnet module. This command includes more double qoutes inside of the perl normal two qoutes for string definition. How can i do this ? this is what i have so far...

$telnet->open($host2)or die "cant open \n" ; my $string = "sysBootFileWrite "QSDvxWorks.aif""; $telnet->cmd($string) or die "cant write freakin command";

Thanks

Replies are listed 'Best First'.
Re: Double Qoutes in string command
by choroba (Cardinal) on Aug 02, 2013 at 14:08 UTC
    Read perlop, especially the Quote and Quote like Operators section. You do not need double quotes here, as there is nothing to interpolate, so you can switch to single quotes:
    my $string = 'sysBootFileWrite "QSDvxWorks.aif"';

    For cases where interpolation is needed, you can backslash the inner double quotes or use the qq operator:

    print "He said, \"Hello, $darling.\""; print qq(He said, "Hello, $darling.");
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ