Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem defining a string

Status
Not open for further replies.

AndyGroom

Programmer
May 23, 2001
972
GB
Hi,

How do I make this line syntactically correct?

$imageHTML = "<img WIDTH=975 HEIGHT=731 border=0 alt='Right-click here and choose Save' src='$server$celebid1024x768.jpg'>";

I guess the combination of apostrophes and speechmarks is confusing the compiler, so how do you include an apostrophe into a string?

Also, will the fact that I'm including $celebid followed immediately by 1024 be an issue? (ie. placing a number immediately after a variable)

Thanks for any help, I'm new at this!


- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
Hi Andy
I have put your code on my server and all is OK.
What is your error?
Keith
 
Try this. It's just a small change to your code that may help:

Code:
$imageHTML = qq(<img WIDTH="975" HEIGHT="731" border="0" alt="Right-click here and choose Save" src=") . $server . $celebid . qq(1024x768.jpg">);

- Rieekan
 
It would be better to use something like below, because if you were using strict mode, compilation would fail due to the fact that there is no variable packaged as $celebid1024x768
Code:
my $server = '[URL unfurl="true"]http://my.com/';[/URL]
my $celebid = 'judy';
my $size = '1024x768.jpg';

my $imageHTML = "<img WIDTH=975 HEIGHT=731 border=0 alt='Right-click here and choose Save' src='$server$celebid$size'>";
 
Thanks guys for all the help, I mixed and matched your answers and came up with this:

$imageHTML = "<img WIDTH=975 HEIGHT=731 border=0 alt='Right-click here and choose Save' src='$server$celebid" . "1024x768.jpg'>";

The compiler didn't seem to like the '1024' coming immediately after the variable.


- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
Another way to deal with variables in the middle of a word is to to do something like this:

src='${server}${celebid}1024x768.jpg'>

which will let perl know what the variable names you are using are.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top