constantlearner
constantlearner

Reputation: 5247

How to define escape character in perl

I want to define a variable /Test123 in perl .I am trying something like this but i am getting error

    my $uriReference="Test123";

    ##Here is where i am  trying to create /Test123

    my $routingUrl = "\"/".$uriReference."\"";

I think i am doing some mistake here Need help?

Upvotes: 0

Views: 98

Answers (1)

TLP
TLP

Reputation: 67900

You can use qq() instead to emulate double quote interpolation:

my $url = qq("/$uriReference");

Although I do not see anything technically wrong with your assignment, it should assign "/Test123" to your variable. So perhaps the error is about something else. We would know if you had included your error message in your question. There is no reason you should ever not include error messages in questions.

You should also know that you do not need to break up your quotes, you can do this:

my $url = "\"/$uriReference\"";

Upvotes: 6

Related Questions