[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Complex URL

Posted on 2006-04-07
Medium Priority
Last Modified: 2012-06-27
I am attempting to feed a complex url (lots of "&"'s and "="'s) to wget, through a system call. I have a feeling that it is a problem with getting perl to send the string to the shell (running on Linux). When I change the command to echo instead of wget, I get:

Can't modify constant item in scalar assignment at <line_number>

The url consists of a first part, which is always the same. The second part is being read from a text file, and then I am appending it to the first half with the $_ variable in a while loop.

Any thoughts?
Question by:stakor
  • 2
  • 2
LVL 39

Expert Comment

ID: 16401177
The & is a special character, and needs to be escaped when in double quotes:

Depending on what is in the string, and if you need to interpolate variables, a different quote operator might be easier to use:

Author Comment

ID: 16401212
Ok, I figured out it is the "&" being fed to the wget command. I need to change all occurences of "&" in my string to "\&".

Author Comment

ID: 16401229
Thanks Adam314. I think the fix would be to do a search and replace on those characters ("&"). Could you post a seach and replace command?
LVL 39

Accepted Solution

Adam314 earned 2000 total points
ID: 16401292
Are there any & anywhere else in your code?  If so, you wouldn't want to do a search/replace on all of those (eg: if($a && $b)   )
I would suggest using the search/replace function of your editor, and review every replace first - to make sure only those you want replaced get replaced.

If you are sure you want to replace every & though, you could use sed:

sed -e 's/\&/\\\&/g' filename

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question