Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

thunders's scratchpad

by thunders (Priest)
on Jun 02, 2004 at 05:42 UTC ( [id://359187]=scratchpad: print w/replies, xml ) Need Help??

use 5.006; use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( 'NAME' => 'Handler::Upload', 'VERSION_FROM' => 'Upload.pm', 'PREREQ_PM' => { mod_perl => 1.29, Apache::Request => 1.3}, 'ABSTRACT' => 'Upload handler for mod_perl', 'AUTHOR' => 'frank <xxxx@xxxx.com>' ); sub MY::test { if ( eval "require Apache::TestMM" ){ Apache::TestMM::generate_script('t/TEST'); Apache::TestMM->clean; return Apache::TestMM->test; } return <<"EOF"; test:: \t\@echo This test suite requires Apache::Test \t\@echo availible from the http-test distribution EOF }

Perl code
#!/usr/bin/perl -w use strict; use MIME::Lite; #stripped down Mailer w/ MIME encoding use HTML::Template; # use IO::File; #for easy file reading my $io = new IO::File "emaillist2.txt"; while ( my $address = $io->getline ){ chomp($address); my $template = HTML::Template->new(filename => 'free_ipod.tmpl'); my $email_html = $template->output; my $msg = MIME::Lite->new( To =>$address, From => 'survey@xxxxx.com', Subject =>'Win a free ipod', Type =>'multipart/related' ); MIME::Lite->send('smtp', "istate1.corp.xxxxx.com", Timeout=>60); $msg->attach(Type => 'text/html', Data => $email_html ); $msg->attach(Type => 'image/gif', Id => 'IS093-043_emailanim.gif', Path => 'IS093-043_emailanim.gif', ); $msg->send(); }

#!/usr/bin/perl open (FILE, "access_log"); @log = <FILE>; close(FILE); open (FILE2, "separate_ips"); @ips = <FILE2>; close (FILE2); foreach $lawg (@log) { chomp($lawg); $lawg =~ /(\d+\.\d+\.\d+\.\d+)/; $ahem = $1; $found = 0; foreach $ip (@ips) { chomp($ip); if ($ip eq $ahem) { ++$found; } } if ($found < 1) { open (FYLE, ">>separate_ips"); print FYLE "$ahem\n"; close(FYLE); push (@ips, $ahem); } }
while(my $row = $sth->fetchrow_hashref ){ push @users, { name => $row->{user} , pc => $row->{pcname} }; } print header,start_html,start_table; print map { Tr(td($_->[0]->{name}),td($_->[0]->{pc})) } sort { $a->[1] cmp $b->[1] } map { [$_, lc(get_lname($_)) ] } @users; print end_table, end_html; $sth->finish; $dbh->disconnect; sub get_lname{ my $nameref = shift; my $name = $nameref->{name}; if ($name !~ /[a-z]/ || $name !~ /[A-Z]/) { return ($name =~ /^\w(\w+)/)[0]; }elsif($name =~ /[A-Z][a-z]/){ return ($name =~ /([A-Z][a-z]+)/)[0]; }else{ return "z"; } }


#!/usr/bin/perl -w use DBI ; use strict; #connect to Access file via ODBC my $accessDSN = q(driver=Microsoft Access Driver (*.mdb);). q(dbq=D:\\Course 1 Case Study Files\\Order Entry System.mdb); my $dbhA = DBI->connect("dbi:ODBC:$accessDSN",'','') or die "$DBI::err +str\n"; #prepare handles for each table. figure out how to do this w/o hardcod +ed names my @tables = qw(Customers OrderLineItems Orders Products); my %tblSth = map {getHandle($_,$dbhA)} @tables; #return_data(%tblSth); my $oPrepare = create_tables(%tblSth); #insert_data(); sub getHandle{ my ($table,$dHandle) = @_; return $table,$dHandle->prepare("select * from $table"); } sub create_tables{ my %tblSth = @_; my %typemap = ( 12=>"VARCHAR", 2=>"NUMBER", -6=>"NUMBER", 11=>"DATE", +4=>"NUMBER"); my $oPrepare ="SET echo on;\n\n"; while( my ($table,$handle) = each %tblSth){ $handle->execute or die "$dbhA->errstr"; my $index = (keys %{$handle->fetchrow_hashref("NAME")}); $oPrepare .= "DROP TABLE $table;\n". "CREATE TABLE $table ("; for my $col(0..$index){ my($column,$type,$size,$digits,$null) = $handle->func($col,"D +escribeCol"); if (defined $column){ if ($digits>0) {$size .= ",$digits"}; $oPrepare .= $column. " ".$typemap{$type}; if ($type != 11){$oPrepare .= "(".$size.")"}; if ($col < $index){ $oPrepare .= ","} } $oPrepare .= "\n"; } $oPrepare .= ");\n\n"; } $oPrepare .= "/"; return $oPrepare; }

Output

SET echo on; DROP TABLE OrderLineItems; CREATE TABLE OrderLineItems ( OrderId NUMBER(10), LineItemNbr NUMBER(10), ISBN VARCHAR(50), Cost NUMBER(19,4), Quantity NUMBER(10) ); DROP TABLE Customers; CREATE TABLE Customers ( CustId NUMBER(10), FirstName VARCHAR(50), LastName VARCHAR(50), CompanyName VARCHAR(50), Address1 VARCHAR(50), Address2 VARCHAR(50), City VARCHAR(50), State VARCHAR(2), Zip VARCHAR(10), Phone VARCHAR(25), Fax VARCHAR(50) ); DROP TABLE Orders; CREATE TABLE Orders ( OrderId NUMBER(10), CustId NUMBER(10), OrderDate DATE, Status NUMBER(3), TotalCost NUMBER(19,4) ); DROP TABLE Products; CREATE TABLE Products ( Title VARCHAR(50), Author VARCHAR(50), ISBN VARCHAR(50), Cost NUMBER(19,4) ); /
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-03-19 02:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found