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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

concat string

Status
Not open for further replies.

clarissa1996

Technical User
Jan 31, 2002
78
0
0
CH
Hi all

the last line return an error.
The problem is how to concat the variable $session->param("company") with a string ?

Thanks a lot. Clarissa


#!/usr/bin/perl
use CGI::Session;
$session = new CGI::Session("driver:File", undef, {Directory=>'/tmp'});
$session->param("company", 1);
$sql = "../../conf/$session->param("company");
 
You need to use the explicit concatenation operator, '.'

Code:
$sql = '../../conf/' . $session->param("Company");

Your problem is that [tt]$session->param("company")[/tt] isn't a variable, it's a method call on an object, and these don't interpolate into strings. If you assign the result of the call to a variable, you can interpolate that:
Code:
my $company = $session->param("company");
$sql = "../../conf/$company";

Yours,

f

["]As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs.["]
--Maur
 
That'll be my over-verbose circumlocuity and sendentious pontification slowing me down again. It's my Achilles heel!

f

["]As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs.["]
--Maur
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top