[PLUG] perl question
Joe Pruett
joey at clean.q7.com
Fri May 29 21:05:12 UTC 2009
> I'm at a loss about why this simple concatenation is not working. I'm
> pulling a value from a hash and attempting to concatenate ".cal" on the end.
>
>
> $Cal_ref = {
> 'cal_name' => $cal_name,
> 'dates' => \@dates,
> 'desc' => $cal_desc
> };
>
> $twsCalendars[$i] = $Cal_ref;
> $i++;
> ...
>
> for (my $i = 0; $i < $length; $i++) {
> # cycle through the list and print all the calendar names
> my $c_href = $twsCalendars[$i];
> my $cal_name = $$c_href{'cal_name'};
> my $foo = ".cal";
> my $var1 = $cal_name . "$foo";
> print ("$cal_name\n");
> print ("$var1");
> print "\n";
> print (" $var1");
> print "\n";
>
> This outputs the following:
>
> BCPFTPCL
> .calTPCL
> .calBCPFTPCL
>
> Whatever I try, I can't concatenate the ".cal" on the end of $cal_name. I've
> moved quotes around, attempted the concatenation to the same var ($cal_name
> = $cal_name . $foo) but nothing seems to work. It seems there are invisible
> characters or $cal_name isn't scalar (I have even forced a scalar context on
> $cal_name, no change in result).
looks to me like you have a \r on the end of $cal_name. you probably need
to do some chop/chomp'ing when you get your data.
More information about the PLUG
mailing list