[Catalyst] hostname

Jason Kohles email at jasonkohles.com
Thu Jan 10 21:13:09 GMT 2008


On Jan 10, 2008, at 3:15 PM, Octavian Rasnita wrote:

> From: "Ash Berlin" <ash_cpan at firemirror.com>
>> How did you get to a function in MyApp.pm during a request....
>>
>> # in MyApp.pm
>>
>> sub foobarbaz {
>>   my ($c) = @_;
>> }
>>
>> # In controller code.
>> $c->foobarbaz();
>>
>> Make sense?
>
> Not really.
>
> I've tried (in MyApp.pm):
>
> sub the_host {
> my ($c) = @_;
> return $c->req->hostname;
> }
>
> and then I've tried to use
>
> cookie_domain => the_host()
> in the MyApp config, but when I try to start the server it gives an  
> error telling that I can't use the method "req" because $c is  
> undefined.
>
Because you didn't define it.  You have to call it as a method ($c- 
 >the_host()), and you have to call it *during a request*.  I don't  
know how you still expect to be able to get a value that is sent by  
the browser during startup when there is no browser.

-- 
Jason Kohles, RHCA RHCDS RHCE
email at jasonkohles.com - http://www.jasonkohles.com/
"A witty saying proves nothing."  -- Voltaire





More information about the Catalyst mailing list