📄 perllecture.html
字号:
<br><NIN_Dude> yes
<br><bitsNbytes> OKay!
<br><bitsNbytes> :)
<br><bitsNbytes> some of you might be wondering why the HELL use Perl
<br><bitsNbytes> there are many reasons ..out of which some are
<br><bitsNbytes> PERL -->Practical Extract Report Language-->
created by Larry Wall
<br>*** BootError has joined #bsrf
<br><bitsNbytes> is one of the most Powerful Scripting language on earth
<br><bitsNbytes> apart from being a scripting language .. it also incorpaorates
the best of C and C++
<br><bitsNbytes> thus in short PERL is a superset of scripting lang,
C and C++
<br>*** [PhaLanX] has joined #bsrf
<br><suspect> Who was the only guy to get his work done by Friday ?
<br><bitsNbytes> the creator and other contributors have now thought
of bringing this power to the Web
<br><suspect> eh ?
<br>*** ^CoaXiaL^ has quit IRC (Quit: )
<br><bitsNbytes> suspect: something important ....?
<br><bitsNbytes> i guess not
<br>* NIN_Dude slaps suspect around a bit with a large trout
<br><bitsNbytes> so let us move on to error handling
<br><bitsNbytes> supposing u have trouble tracking down you scripts
warnings
<br><bitsNbytes> and error mesages, or your scripts STDERR output is
confusing you
<br>*** kamm has quit IRC (Quit: Leaving)
<br><bitsNbytes> we use the CGI::Carp module
<br><bitsNbytes> it is easy to understand if u know C++
<br><bitsNbytes> it is analogous to using a class called CGI
<br><bitsNbytes> and the "carp" portion of it
<br>*** essex has quit IRC (Read error: 104 (Connection reset by peer))
<br><bitsNbytes> i will now create a small prototype
<br><bitsNbytes> to redirect errors to files of your choice
<br><bitsNbytes> BEGIN
<br><bitsNbytes> {
<br><bitsNbytes> i wonder why nobody has any doubts
<br><bitsNbytes> guess either i am talkin to myself or i am speaking
in ancient phoenetix
<br><bitsNbytes> anywaz
<br><bitsNbytes> BEGIN
<br><bitsNbytes> {
<br><HardW1r3> im listening
<br><sohed> me too
<br>* NIN_Dude raises his hand
<br><bitsNbytes> use CGI::Carp qw(carpout);
<br>*** X is now known as Pr0nKing
<br><bitsNbytes> yes
<br>*** Pr0nKing is now known as P0rnKing
<br><bitsNbytes> NIN_Dude:........?
<br><NIN_Dude> um.. BEGIN?
<br><NIN_Dude> as in class?
<br>*** fatboyjoe has left #bsrf
<br>* NIN_Dude cries
<br><bitsNbytes> yes exactly
<br><NIN_Dude> oh aight
<br><bitsNbytes> notice the "qw" i am using frequently
<br><bitsNbytes> it stands for quote words and is a wonderful lil reserved
word
<br><bitsNbytes> OK .. lemme switch back to basics and discuss a small
simple perl program to
<br><bitsNbytes> make things more clearer
<br>*** [PhaLanX] has quit IRC (Quit: )
<br><bitsNbytes> #! usr/bin/perl -w
<br><bitsNbytes> print "Identify yourself!";
<br><bitsNbytes> $name = <STDIN>;
<br><bitsNbytes> chomp ($name);
<br><bitsNbytes> if ($name eq "PootieTang")
<br><bitsNbytes> {
<br>*** jacs has quit IRC (Quit: )
<br><bitsNbytes> print " Hi there Pootie, You r simply the best!\n";
<br><bitsNbytes> }
<br><bitsNbytes> else{
<br><bitsNbytes> print "Who r U $name\n";
<br><bitsNbytes> }
<br><NIN_Dude> chomp?
<br><NIN_Dude> parsin?
<br><bitsNbytes> coming .. to it
<br>*** Kamikaze has joined #bsrf
<br><Kamikaze> what is an stdin, stdout, and stderr?
<br><NIN_Dude> ok
<br><NIN_Dude> standard
<br><NIN_Dude> input
<br>* NIN_Dude shuts up
<br><Kamikaze> aye...........
<br><bitsNbytes> chomp cuts out the newline character
<br><Kamikaze> not really much help but thanks anyway
<br><bitsNbytes> the entire string is taken along with the newline char
also a part of it
<br><bitsNbytes> so u need to cut it off
<br><Kamikaze> oh I see the tutorial is underway, sorry for interrupting
<br><bitsNbytes> there is a function called "chop" also
<br><NIN_Dude> does chomp cut off the last char or just the newline?
<br><bitsNbytes> good question NIN
<br><bitsNbytes> chop does cut off the last char
<br><bitsNbytes> but not ole chomp
<br><HardW1r3> dammit this sounds like school
<br><Kamikaze> lol
<br><bitsNbytes> it just does away with the \n
<br><bitsNbytes> hehe
<br><bitsNbytes> is it clear ;)
<br><Kamikaze> really sorry for interrupting here but have you covered
website redirection yet?
<br><bitsNbytes> i have covered basic perl-cgi script and error redirection
<br><Kamikaze> yeah yeah I know everyones gonna /ignore kamikaze :)
<br><bitsNbytes> and will come to that just in a few moments
<br><bitsNbytes> actually i have a hell lot to say
<br><bitsNbytes> and very lil time i suppose
<br>*** P0rnKing is now known as X
<br><bitsNbytes> how long do the lectures go on usually
<br>* Kamikaze shuts up and listens up
<br><bitsNbytes> this is the first time i am delivering one
<br><Kamikaze> as long as it takes till ppl are satisfactory
<br><Kamikaze> satisfied^
<br><bitsNbytes> k..fine
<br><bitsNbytes> so is the basic structire of a perl prog clear
<br><sohed> yes
<br><Kamikaze> nope I missed it :)
<br>*** s4m1k has joined #bsrf
<br><bitsNbytes> then i revert back to the main topic of discussion
<br>* Kamikaze will really shutup now... promise
<br>*** ExposedTruth has quit IRC (Quit: )
<br><bitsNbytes> now back to CGI_Perl
<br><bitsNbytes> man the connection here in India sux
<br><bitsNbytes> it is crawling
<br><bitsNbytes> let us have a nice Graphical Interactivity
<br><Kamikaze> I'm now reading 'Teach yourself C in 21 days'
<br>*** fatboyjoe has joined #bsrf
<br><bitsNbytes> hmm
<br><Kamikaze> oops wrong chan
<br><Kamikaze> shite
<br>*** s4m1k has quit IRC (Quit: [x]chat)
<br><Kamikaze> it's best if I leave
<br>*** Kamikaze has left #bsrf
<br><bitsNbytes> any doubts so far
<br><bitsNbytes> any damn doubt that may be troubling anyone
<br><NIN_Dude> what if it's not running UNIX?
<br><bitsNbytes> then anyway u have to find a way to get ur program
on the server
<br><bitsNbytes> the web server..in the right location
<br><bitsNbytes> the right path i mean
<br><bitsNbytes> i am not familiar with the procedure for windowz tho
<br><bitsNbytes> only when it is on the server .. can ur script
be of any use
<br><bitsNbytes> i have told .. how to get it running on UNIX
<br><bitsNbytes> ok .. comin to where I left
<br><bitsNbytes> the function for redirecting error messages
<br><bitsNbytes> u have to try this .. code and learn
<br><bitsNbytes> coz i have made it rigfht now
<br>*** fatboyjoe has left #bsrf
<br><bitsNbytes> so .. u get my point...;)
<br><bitsNbytes> BEGIN {
<br><bitsNbytes> use CGI::Carp qw(carpout)
<br><bitsNbytes> open (LOG, ">>/var/local/cgi-logs/junk-error")
<br><bitsNbytes> or die "Unable to append to junk-error: $!\n";
<br><bitsNbytes> carpout(*LOG);
<br><bitsNbytes> }
<br><bitsNbytes> the carpout parameter is to carp-out or blurt out warnings
or error returns
<br><bitsNbytes> die is like exit()
<br><bitsNbytes> to handle fatal errors
<br><bitsNbytes> u can use
<br><bitsNbytes> use CGI::Carp qw(fatalsToBrowser);
<br><bitsNbytes> die "Fatal Error here!!";
<br><bitsNbytes> Even if the error occurs before u get the HTTP header
out
<br><bitsNbytes> the module will try to take care of this to avoid the
dreaded "500 server error"
<br><bitsNbytes> how many of u r on a *NIX box
<br><sohed> now?
<br><bitsNbytes> yeah
<br><bitsNbytes> or maybe do use a nix box freq.
<br>*** snider has joined #bsrf
<br>*** ChanServ sets mode: +o snider
<br><sohed> i use it frequently but not right now
<br><bitsNbytes> anyway .. even after taking care of errors if you happen
to get the 500 server error
<br><bitsNbytes> it means two things
<br><bitsNbytes> on a Unix system either you dont have the right permissions
<br><bitsNbytes> u can check that with the ls -l and assign the script
(on the server of course) a 0755 pemission
<br><bitsNbytes> 0755 if u owned it
<br>*** Satori has joined #bsrf
<br><bitsNbytes> and 0555 owned by the designated user, assuming u r
the SU
<br><bitsNbytes> SU = super user
<br>*** Dustin has joined #bsrf
<br><Dustin> kernel question:
<br><bitsNbytes> also name it with a .cgi extension or .plx ext
<br><Dustin> the docs in one place say to use 2.7.2.3 to compile 2.4.6
<br><Dustin> in another it says NOT to use it
<br><Dustin> what gcc version do i need?
<br><Dustin> 2.7.2.3 or 2.91.66 ?
<br><bitsNbytes> tho not necessary some servers identify the ext also
<br>*** suspect has quit IRC (Ping timeout: 180 seconds)
<br><bitsNbytes> Dustin: The latest
<br><bitsNbytes> in ur case 2.7 will do
<br><Dustin> i compiled a while ago with 2.96. something and got lots
of errors
<br><bitsNbytes> i maean 2.7.2.3
<br><Dustin> ok
<br><bitsNbytes> wht errors
<br><Dustin> even though it says "*gcc 2.7.2.3 is no longer supportes*"
<br><Dustin> uhm,
<br><bitsNbytes> yeah module and version dependencies are quite annoying
and can be solved best by trial and error
<br>*** zwanderer has joined #bsrf
<br><Dustin> let me rephrase it: it complied badly
<br><Dustin> x wouldnt start, lots of cryptic x errors
<br><bitsNbytes> heheh i know it happens
<br><bitsNbytes> anyway.. we are here for something else
<br><bitsNbytes> a lecture is in progress
<br><Dustin> oh shit
<br><bitsNbytes> so .. if u plz
<br>*** SkyLemon has joined #bsrf
<br><bitsNbytes> are the others listening
<br><SkyLemon> Hello, I need some help: What is the file on linux that
you edit to shutdown any services / close ports??
<br><NIN_Dude> ...
<br><bitsNbytes> for any queries regarding linux plz post them on messg
board or mail me at tejanshu@rediffmail.com
<br>*** Jesteruk has joined #bsrf
<br><bitsNbytes> but plz do not go off the track
<br>*** suspect has joined #bsrf
<br><Jesteruk> hum...hello peeps
<br><NIN_Dude> just keep going bits
<br><bitsNbytes> yeah .. ..
<br><Jesteruk> damn it i missed the lecture
<br><bitsNbytes> a simple silly thing
<br><Jesteruk> never poo poo a lecture dude
<br>* NIN_Dude kills jester
<br><bitsNbytes> if u want to compile a perl prog
<br><Jesteruk> ah i see, nah i only write iot for CGI purposes
<br><NIN_Dude> STFU
<br><bitsNbytes> just use perl -wc cgi-script name=joe number=10
<br><bitsNbytes> at the command prompt
<br>*** HardW1r3 has quit IRC (Ping timeout: 180 seconds)
<br>*** SkyLemon has quit IRC (Quit: )
<br><bitsNbytes> this checks the validity of the program as well as
runs with the mock input
<br><Jesteruk> aaah i see..i didnt know that
<br><Jesteruk> i got an apache web server setup..PHP mySQL support,
and perl..i test em that way, didn't know you could simulate it liek that
thru DOS prompt
<br><bitsNbytes> well u know now ;)
<br><NIN_Dude> DOS?
<br><Jesteruk> aye, NIN
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -