Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

add info to $?

add info to $?

add info to $?

Probably a simple question but I can’t manage to get it work. How do you add something to a “$”.
For example:

$string = “hi, there.”;
$string = $string + “How are you”;  (or  eval($string)+”how are you”)

doesn’t work to create $string = “hi, there. How are you?”

So, what would be the correct syntax to add contents to the present value of the $?



RE: add info to $?

use '.='

$string = 'hi';
$string .= ', there';
print $string; # prints 'hi, there'

keep the rudder amid ship and beware the odd typo

RE: add info to $?

Thank you goBoating for helping,

$string .='It did work but only partially as <these thingies and everything between it> is ignored!';

with the print result:

It did work but only partially as is ignored!

I tried to put everything between "" like:
$string .='"<something here> and here"';

But didn't work, can this be solved?


RE: add info to $?

hi jett,

its strange that ur <... > r not being printed. send the code..

actually with '' u r asking for no interpretation of special characters... with " " u ask for them to be interpreted.

now <> r not specail characters AFAIK


RE: add info to $?

I'm sorry. What's happening is that everything between <> is not printed BUT it is included in the $ (as seen by schecking the source).

So it is doing what I wanted to. But there is another problem as parts of the contents is formed by individual $'s and it doesn't show the value of the string but the $ itself like:


"How are you? I'm doing $string!"

If I put everyting between "" instead of '' the script doesn't work!

Now I'm stuck on this!


RE: add info to $?

hi jett,

Paste the entire code snippet. If u have just these three lines:

my $string="fine";
print "How are you? I'm doing $string!"
print 'How are you? I'm doing $string!'

$ perl mytest.pl
How are you? I'm doing fine!
How are you? I'm doing $string!
now tell me what is the problem

RE: add info to $?

are you printing to a browser?  
If so, the browser will not know how to interpret non-compliant HTML tags and they will disappear from the browser display.  If that is the case, you should be able to view the page source in the browser and see the entire output.

If you are not printing to a browser, try to trim your code down to a few problem lines and post them here.

keep the rudder amid ship and beware the odd typo

RE: add info to $?

What I'm trying to do is search through a datafile and create some html code when a $ match a field, it does work except from showing the corresponding field which is ouputted as $var. The code looks like this:

if ($var eq $input{'office'}) {
     $result .='<option value="$var">$var</option>/n';

Changing '' into "", like:

if ($var eq $input{'office'}) {
     $result .="<option value="$var">$var</option>/n";

doesn't work (error)!

goBoating, I'm printing to a browser and you're right it does show the complete $ in the source code, it works exactly as I hoped it would except the $var problem.

RE: add info to $?

Problem is solved, probably not really elegant but this is what I did:

$result .="<option value=$add$var$add>$var</option>";

Thanks for all the help,


RE: add info to $?


$result .="<option value=\"$var\">$var</option>/n";



RE: add info to $?

I tried, but it still gives errors,


RE: add info to $?

Yes it did work Shail, in my first attemp I misstyped it (\"$var"\).

Thank you,


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close