전체 페이지뷰

2012년 8월 6일 월요일

Perl Study !!!



I thought pretty easy to learn new computer languages
because I have been studied with Java for 4 years.

But Perl is new World ....It's hard to learn
I'll try to practice and study Perl anyway

1. Learning Perl
2. Practical mod Perl

Is it enough to study Two Perl Language Books ?
Anyway I practice the Perl


First
use strict;
that variable I don't know. But I create the sample pl Script as Perl Base Format
with EditPlus

That format contains the that variable
therefore  I thought just common specification library
But $var didn't compile.  Because I never mind the the that variable

The error is requires explicit packages ..
I googling the error. solving is setting a global value.
but I don't spec Perl

therefore I take the simple solve that variable make comment

I must study more about common lib and variable range first.


http://modperlbook.org/html/22-3-6-Global-symbol-foo-requires-explicit-package-name.html

my  $var  ? what is that my ?

22.3.6. Global symbol "$foo" requires explicit package name

#!/usr/bin/perl -w
use strict;
print "Content-type: text/html\n\n";
print "Hello $username";
Since Perl will insist that all variables are defined before being used, the program will not run and will print the error:
Global symbol "$username" requires 
explicit package name at /home/httpd/perl/tmp.pl line 4.
Moreover, in certain situations (e.g., when SIG{_ _DIE_ _} is set toCarp::confess( )) the entire script is printed to the error_log file as code that the server has tried to evaluate, so if this script is run repeatedly, theerror_log file will grow very fast and you may run out of disk space.
This problem can easily be avoided by always declaring variables before using them. Here is the fixed version of our example:

#!/usr/bin/perl -w
use strict;
my $username = '';
print "Content-type: text/html\n\n";
print "Hello $username";





댓글 없음:

댓글 쓰기