Friday, September 01, 2006

tips tips

as perfaq9, 我们可以通过如下代码得到本机的 IP 地址:
use Sys::Hostname;
use Socket;
my $host = hostname();
my $address = inet_ntoa( scalar gethostbyname( $host || 'localhost' ) );
print $address

PS, the previous post, the "single and find" one shows that ->single don't support order_by attribute, but ->find support it. :)

Want to get a session data by sessionid in Catalyst?
u can insert a seesion_id in TT by [% c.sessionid %]
code like:
my $sid = $c->req->param('sid');
$c->log->debug("sid is $sid");
my $session_data = $c->get_session_data("session:$sid");
return $c->res->body(Dumper($session_data));

don't forget the "seesion:" before $sid.

Good luck.

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home