Database Programming With Perl

Preparing link to download Please wait... Attached file not found

E-Book Overview

Welcome to Perl Training Australia’s Database Programming with Perl training module. This is a two day training module in which you will learn how to interact with databases through Perl. Course outline • Accessing the database • Programming with DBI • SQL::Abstract • Transactions • Database security • Class::DBI • Removing passwords from your programs • Working with remote connections Assumed knowledge This training module assumes the following prior knowledge and skills: • Intermediate Perl fluency, including a familiarity with Perl variable types and references, file input/output, system interaction and using Perl modules. Some experience of using Perl objects would be useful. • Basic Unix fluency, including logging in, moving around directories, and editing files Module objectives • Understand what a database is and why we use them • Understand basic SQL commands • Be able to use the database shell to access the database • Understand why Perl’s DBI exists • Use DBI to add, update, delete and select data in the database. • Understand and use content from extra material.

E-Book Content

Database Programming with Perl #!/usr/bin/perl use strict; print "\nSaid the Llama to the Lama:\n"; my (@Llama, %answers, @llama, @questions) = map{ print;$_ }(); die "seeking a llama to share pipe!\n" unless $Llama[0]=~/Find/; print "\nSaid the Lama to the Llama:\n"; my$karma=0 ;for ( @Llama ){chomp; ; chomp; s/Fi/Fou/;s/−/−−/; ;/ /; my ( $lama, $llama ) = ($‘,$’); s/ //g for( $lama , $llama); $|=0;push @questions,$llama unless $llama=~ /^$/ ; push @llama,# $lama unless $lama=~ /^$/} %answers = map { $_ , 0, scalar reverse( split // ) ,0 }@questions;my @karma=llama( @llama);my @dharma = llama(map { ( ’ ’) x $_ . $llama[$_]. (’ ’) x (1* $#llama −$_)}(0..$#llama)); my @lama=map{$a = $_;;;;; s/( *)(\w+)( *)/$3$2$1/; $a}@dharma; my %find = (lama => \@llama,dharma =>\@karma,karma =>\@dharma ,llama=> \@lama); sub llama{map{$|++; my $grazing= $_ ;join( ’’, map{ ( split //,$_[ $_ ]) [$grazing] } (0..$#_ ))}(0.. ( length($_[0])−1))}sub dharma{my @llama = @{$_[0]} ;[map{s/[a−z]/\*/g;; ; $_}@llama ] };; my %llama= map{$_,dharma($find{$_}) } ( keys %find );; sub karma { my $reasons=shift ;; ; ; my @answers = @{ $find{ "$reasons" } };; for my $questions (keys%answers){next if $answers{ $questions }; study $questions;for (0.. $#answers ) { if ( $answers[ $_]=~/$questions/){my($soul ,$seeks , $to_know )=($‘,$’ ,$&) ;s/\w/\*/g for ($seeks, $to_know, $soul);$llama{ $reasons} −>[$_]=$soul . $questions .$seeks;$karma ++;$answers{ $questions} ++ ; $answers{ reverse( split//,$to_know)}++ }}}};for(keys %find){ karma($_ )};[email protected] =map{$a= $_;$a=~s/./\*/g;$a} (@llama); for my $karma(keys %llama){ $llama {$karma}=[ llama( @{$llama{$karma}})] if $karma=~/.{5}/ ;for(0 .. $#{$llama{$karma}}){ $llama{$karma}−>[$_] =~s/ //g;[email protected] =split//, $dali[$_];my @lAma= split//,$llama{$karma}−>[$_];$dali[$_]= join(’’,map{($lAma[$_] ne ’*’) ? $lAma[$_]:$Lama[$_]}(0..$#lAma));}}my @answer=map { s/(.)/$1 /g ;s/\*/ /g; ($_,’ ’x(length($_)))}(@dali);my($llama,$lama)=sort($#questions, $#answer) ; for (0..$lama) {print $answer[$_]," ",$questions[$_],"\n" } Jacinta Richardson Paul Fenwick Database Programming with Perl by Jacinta Richardson and Paul Fenwick Copyright © 2005-2007 Jacinta Richardson Copyright © 2005-2007 Paul Fenwick Copyright © 2005-2007 Perl Training Australia Cover artwork Copyright(c) 2001 by Frank Booth. Used with permission. Conventions used throughout this text are based upon the conventions used in the Netizen training ma