I am relatively new to Perl. I am trying to store a URL in a variable. Here's my code:
my $port = qx{/usr/bin/perl get_port.pl};
print $port;
my $url = "http://localhost:$port/cds/ws/CDS";
print "\n$url\n";
This gives me the below output:
4578
/cds/ws/CDS
So the get_port.pl script is giving me the port correctly but the URL isn't getting stored properly. I believe there's some issue with the slash / but I am not sure how to get around it. I have tried escaping it with backslash and I have also tried qq{} but it keeps giving the same output.
Please advise.
Output for perl get_port.pl | od -a
0000000 nl 4 5 7 8 nl
0000006
perl yourscript.pl | hexdump -Cmight be helpful. (and how aboutqx{}?)qxis not terminated), so it is not the code you ran to produce your results (because it won't run, period). Also, even if we could run it, we don't have yourget_port.plprogram, so we would get different results for reasons completely unrelated to your question./usr/bin/perl get_port.pl | od -c?