CGI/PERL INTERACTIVITY PERL is used in CGI sripts 99% of the time. Easiest way for interactivity. Send Email, set cookies, read and write from and to test files. + added security. /almost always found on Unix or Linux Web Servers. Perl used for Databases - but needs modules. PHP and mySQL is becoming the deFacto standard for mySql. Creating and uploading CGI scripts. Stored on the server in cgi-bin or occasionally cgi. Extension pl or cgi. Here we go. Result! Lycos site - no Perl enabled. One&One - Perl enabled! and working fine, brill. Upload with WS-FTP Pro. Set ftp address, login and password - and your ready to go! Upload Perl scripts, select in WS_Ftp, r-click, ftp-commands, CHMOD(change mode - the file permissions. Group, USER, Author read,write, execute permissions. rwe --- --- and all that.) Set to 755 to make generallly executable. Lovely, we're all set to do a bit of Perl. find host who lets you do perl - no excuse nowadays, indicates ignorance if problems. You need full access for full interactivity - get clients to change hosts oif problems. Need to read and write to dat files. If Telnet, command is - chmod 755 filename (pl or dat file). Basic PERL Scripts Content type line is essential, in order to display data on a web page or get it back into Flash correctl - you must set the type of data you are outputting. It's an essential scripting element, not output to the page. Print is sef-evident. Don't need to concatinate quoted text with avariable using +, like in AS. (_root.ouput = _root.pet+"= A Great Pet to own") Perl recognises strings present within a quoted print statement(is that clear?). Need to escape certain characters, obviously the $ sign, via (\) backslash. Need to escape all Perl reserved chars that you intend to print in a print statement. exit; is always the last line in Perl. Perl Commands are like actionscript.
Basic Perl commands: Vars and Arrays another array type is hash or associative array. Ref with keys instead o fnumbers. Hash array as a whole is ref by (%). Ex: %carColors = ("Camero",
"Red", "Mustang", "Blue", "Corvette",
"Yellow"); or %carColors = (Camero => "Red", etc) A key can be ref with another variable eg: $osmeCar = "Mustang"; Special Perl Environment
Vars always available as long as
data present. to retrieve data: $ENV{ 'environment_variable'} Test Link to environment.pl
on Johns Site here
Excellent it works! Code in the environment.pl file:: AH! - So you could tell if someone has linked to you. It's a powerful tool the env Vars. Can test for cookies, prevent people from calling you from thier own websites or desktops. Moving data from Flash to Perl.
Straight forward. Perl file on server: Checks to see POST or GET. POST
- neads the extra code read(), puts what it finds in var $allPostData
(can call what you like). Sends it all back as a string. # Display
the final output on the web page This is Crucial so Line by Line. @variables = split(/&/, $allWebData); // Perl takes the long string and breaks it at every (&), ending up with pairs in @variables. :: favColor1=Blue. But it still looks like a string to Perl not name/value pairs , so it has to split again. Next code splits and puts into proper associative hash array:: foreach $pair(@variables){
//goes through each value in the array specified in the parenthesis
- and performs the operations in the curly braces on each value(naming
the values as $pair).
foreach $i (keys %DATA)
{
Now Perl can deal with the vars on individual basis. Change code: foreach $i (keys %DATA)
{ Upload, change textfields to number data - see perl perform. All this is to show what goes on behind the scenes. Sometimes breaking up data unecessary, but need to know how it's done. This is Difficult, so I've spelled it out on the next page, you need to fully understand what'sgoing on - we're getting there!
|
||