2014-04-25 3 views
0

mojocasts 에피소드 2와 함께 mojolicious를 배우십시오. 내가 서버에서이 오류 주소 http://127.0.0.1:3000/sayth/renshaw로 이동 그러나 때mojolicious - barewords - mojocast 2

나는

#!/usr/bin/env perl 
use Mojolicious::Lite; 

get '/:fname/:lname' => sub { 
    shift->render('hello'); 
}; 

app->start; 

__DATA__ 

@@ hello.html.ep 
<!doctype html><html> 
    <head><title>Placeholders</title></head> 
    <body><i>Hello <%= fname %> <%= $lname %></li></body> 
</html> 

의 예제를 가지고있다.

[Fri Apr 25 15:59:05 2014] [error] Bareword "fname" not allowed while "strict subs" in use at template hello.html.ep from DATA section line 3, <DATA> line 17. 
1: <!doctype html><html> 
2:  <head><title>Placeholders</title></head> 
3:  <body><i>Hello <%= fname %> <%= $lname %></li></body> 
4: </html> 

엄격한 서브를 지정했다고 생각하지 않습니다. 어떻게 해결합니까?

편집 : perl 5.16.3이 설치된 컬 (curl)로 설치된 최신 버전을 실행 중입니다.

+1

템플릿의'fname' 앞에'$'가 필요합니다. – stevenl

답변

3

Mojolicious는 기본적으로 use strict;을 사용합니다.

Bareword "fname" not allowed while "strict subs" in use at template hello.html.ep 

기본적으로, 당신은 단지 fname 전에 달러 기호를 놓치고 :

@@ hello.html.ep 
<!doctype html><html> 
    <head><title>Placeholders</title></head> 
    <body><i>Hello <%= $fname %> <%= $lname %></li></body> 
</html> 

또는 당신이 펄 코드를 얻을 것 같은 :

오류가 동일 감사

@@ hello.html.ep 
<!doctype html><html> 
    <head><title>Placeholders</title></head> 
    <body><i>Hello <%= param('fname') %> <%= param('lname') %></li></body> 
</html> 
+0

mojolicous가 스크린 캐스트 이후 업데이트 되었기 때문에 그렇게 될 것입니다. – sayth

관련 문제