• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Perl 1997 Perl As A System Glue
 

Perl 1997 Perl As A System Glue

on

  • 1,095 views

This presentation, at the 1st Perl Conference, introduced cross platform perl/unix web development. Of special interest was the examination of what are now called database sockets. This may have ...

This presentation, at the 1st Perl Conference, introduced cross platform perl/unix web development. Of special interest was the examination of what are now called database sockets. This may have been the first presentation of the subject.

Statistics

Views

Total Views
1,095
Views on SlideShare
1,094
Embed Views
1

Actions

Likes
1
Downloads
8
Comments
0

1 Embed 1

http://www.slideshare.net 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Perl 1997 Perl As A System Glue Perl 1997 Perl As A System Glue Presentation Transcript

    • Perl As A System Glue Patrick M. Benson University of Washington Information Systems http://weber.u.washington.edu/~pbenson email: pbenson@cac.washington.edu
    • Overview of Examples
      • File Store-and-Forward
      • Introductory Level Example
      • Perl CGI
      • Intermediate Level Example
      • Half-a-Perl Concept
      • SQL Development
    • File Store-and-Forward
      • VAX/VMS with Multinet outside our firewall running FOCUS under DCL
      • RS-6000 UNIX/AIX inside our firewall with strict security measures
      • IBM-309x/VM with an unknown Comm System on dedicated RJE line through our firewall
    • File Store-and-Forward
    • File Store-and-Forward
      • RSH and FTP work because ...
      • I trust you enough to let you talk to me, I’ll take data files you say are safe.
      • You trust me enough to give me your account / password and to let me send a copy of your data file back to you.
      • Perl in this process (See Listing 2, RS6000/AIX Perl Script)
      • IF Statements, Logical Operators, Code Blocks
      • 16. if ($#ARGV != 1) {
      • 17. print “ *******************************************”;
      • 18. print “ * ARGUMENT MISMATCH ERROR #”, $#ARGV *”;
      • 19. print “ ******************************************* ”;
      • 20. exit -1;}
      • Arguments, Array Notation, Concatenation, Constants
      • 23. $infile = $ARGV[0];
      • 24. $chkfile = $infile . ‘_check’;
      • Back-Tic Execution, Nested Quotes, Imbedded Pipes
      • 43. $get_file = ‘echo “get $outfile $chkfile” | ftp vsvm.dis.wa.gov‘;
      File Store-and-Forward
    • Overview of Examples
      • File Store-and-Forward
      • Introductory Level Example
      • Perl CGI
      • Intermediate Level Example
      • Half-a-Perl Concept
      • SQL Development
    • Perl CGI
      • Web Client (PC, Mac, Xterm with Netscape 2.1 or better or similar, marginal HTML 3.0 or better compliant)
      • Web Server (Perl 4.2 or better)
      • Data Server (Unix Box with Informix, Sybase, Oracle ISQL or similar)
    • Perl CGI
    • Perl CGI
      • Content, Cache Control, Libraries, Initialization
      • Accept static HTML parameters & Main Driver
      • Construct ISQL command to meet request
      • Copy the ISQL command through the firewall to a data file
      • Pass filename and CAT statements as a parameter to ISQL command file
      • Parse returned string into rows
      • Build HTML Page
    • Perl CGI
      • See Listing 3, Perl CGI
      • Content, Cache Control, Libraries, Initialization
      • 9. print "CONTENT-TYPE: text/html"," ";
      • 10. print "Pragma: no-cache"," ";
      • 12. require "/www/world/cgi-bin/cgi-lib.pl";
      • 14. $rcp_user = ‘oasis’;
      • 15. $rcp_cmd = ‘/usr/ucb/rcp’;
      • 16. $rcp_host = ‘equip.u.washington.edu’;
      • 18. $rsh_user = ‘oasis’;
      • 19. $rsh_cmd = ‘/usr/ucb/rsh’;
      • 21. $sql_host = ‘equip.u.washington.edu’;
      • 22. $sql_db = ‘oasisdev@equipdev’;
      • 27. $rcp_destination = $rcp_user . ‘@’ . $rcp_host . ‘:.’;
      • 28. $sql_user = $sql_host . ‘ -l ‘ . $rsh_user . ‘ ‘;
    • Perl CGI
      • See Listing 3, Perl CGI
      • Accept static HTML parameters & Main Driver
      • 37. &ReadParse;
      • 39. $table_name = $in{'table_name'};
      • 41. $set_extract;
      • 42. &run_extract;
      • 43. &write_report;
      • 45. exit;
    • Perl CGI
      • See Listing 3, Perl CGI
      • Construct ISQL command to meet request
          • 49. sub set_extract {
          • 53. $sellist = ‘name_value, name_full_text’;
          • 54. $passlist = “'$table_name'”;
          • 55. $sql_tables = ‘UNLOAD TO TEMPTBL SELECT ‘ . $sellist
          • 56. . ‘ FROM names’
          • 57. . ‘ WHERE name_type = ‘ . $passlist
          • 58. . ‘ ’;
          • 59. }
    • Perl CGI
      • See Listing 3, Perl CGI
      • Copy the ISQL command through the firewall to a data file
          • 76. $info_time = `$rsh_cmd $sql_user "/bin/date "`;
          • 77. if ($info_time eq '') {
          • 78. print &quot;<P>Database Server not responding ... try again later.&quot;;
          • 79. exit;
          • 80. }
          • 85. $d = `rcp isql_tables.sql $rcp_destination`;
    • Perl CGI
      • See Listing 3, Perl CGI
      • Pass filename and CAT statements as a parameter to ISQL command file
      • 94. $info = `rsh $sql_user &quot;$rsh_file $sql_db isql_tables.sql; cat -e -v TEMPTBL ; rm TEMPTBL&quot;`;
    • Perl CGI
      • See Listing 3, Perl CGI
      • Parse Returned String into Rows
      • 100. @table_data = split('|$',$info);
      • 101. $row_count = $#table_data;
      • 102. @row_data = split('|',$table_data[0]);
      • 103. $col_count = $#row_data + 1;
    • Perl CGI
      • See Listing 3, Perl CGI
      • Build HTML Page
      • 108. sub write_report {
      • 110 &build_headers;
      • 111. &write_header;
      • 112. &write_body
      • 113 &write_footers;
      • 114. }
    • Perl CGI
      • See Listing 3, Perl CGI
      • Build HTML Page - Build Headers
      • 122. $table_title[0] = ‘Column 1’;
      • 123. $table_title[1] = ‘Column 2’;
      • 125. if ($table_name eq “class”) {
      • 126. $table_title[0] = ‘Class Code’;
      • 127. $table_title[1] = ‘Class of Equipment’;
      • 128. elsif ($table_name eq &quot;cond&quot;) {
      • 129. $table_title[0] = ‘Condition Code’;
      • 130. $table_title[1] = ‘Asset's Present Condition’;}
      • (and so on until all possible table column titles are set)
      • 140. }
    • Perl CGI
      • See Listing 3, Perl CGI
      • Build HTML Page - Write Header
      • 144. sub write_header {
      • 148. print <<end_of_header;
      • 149. <HTML>
      • 150. <HEAD><TITLE>
      • 151. Table Contents Inquiry
      • 152. </TITLE></HEAD>
      • 153. <BODY
      • 161. end_of_header
      • 162. }
    • Perl CGI
      • See Listing 3, Perl CGI
      • Build HTML Page - Write Body - Table Header
      • 175. print &quot;<P> <TABLE COL=$col_count BORDER=&quot;1&quot; &quot;;
      • 176. for ($i = 0; $i < $row_count; $i++) {
      • 180. if ($i == 0) {
      • 181. print &quot;<THEAD><TR>&quot;;
      • 182. for ($j = 0; $j < $col_count; $j++) {
      • 183. print &quot;<TD ALIGN=&quot;CENTER&quot;> $table_title[$j] </TD>&quot;;
      • 184. }
      • 185. print &quot;</THEAD><TBODY>&quot;;
      • 186. }
    • Perl CGI
      • See Listing 3, Perl CGI
      • Build HTML Page - Write Body - Table Rows
      • 195. @row_data = split('|',$table_data[$i]);
      • 196. for ($j = 0; $j < $col_count; $j++) {
      • 197. if ($j == 0) {
      • 198. $row_data[0] =~ s/xA//g;
      • 199. print &quot;<TR><TD><FORMMETHOD=&quot;GET&quot;ACTION=&quot;./update_table.cgi&quot;>
      • 200. <INPUT TYPE=&quot;hidden&quot; NAME=&quot;$table_name&quot;
      • 201. VALUE=&quot;$row_data[0]&quot;>
      • 202. <INPUT TYPE=&quot;SUBMIT&quot; VALUE=&quot;$row_data[0]&quot;></FORM></TD>&quot;;
      • 203. } else {
      • 204. print &quot;<TD> $row_data[$j] </TD>&quot;;
      • 205. }
      • 206. }
    • Perl CGI
    • Perl As A System Glue
      • Pluses
      • Cost effective cross platform superglue.
      • Efficient and Structured code possible
      • 1 hour of Perl = 8 hours of COBOL
      • Minuses
      • 10 ways to mess up maintenance staff
      • Difficult post-implementation support environment
      • All the HTML Bandwagon problems