Complex URL

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?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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:'-''-%22-%22%22-%2f%2f-%60-%60%60-%3c%3c-escape-sequence-escape
stakorAuthor Commented:
Ok, I figured out it is the "&" being fed to the wget command. I need to change all occurences of "&" in my string to "\&".
stakorAuthor Commented:
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?
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.