Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

DigitalKitty's scratchpad

by DigitalKitty (Parson)
on Jun 02, 2004 at 00:42 UTC ( #358909=scratchpad: print w/ replies, xml ) Need Help??

CB database tool (work in progress)

use warnings; use strict; use LWP::Simple; use DBI; my $data = ''; my $dbh = ''; my $url = 'http://www.perlmonks.org/?node_id=207304'; my $pat = qr{ <author>(.*?)<\/author>.*?<text>(.*?)<\/text> }xs; $dbh = DBI->connect( "dbi:SQLite:dbname=C:\\testdb", "", "" ); $data = get( $url ); while ($data =~ m/$pat/msg) { my ($auth, $text) = ($1, $2); for( $text ) { s/[ ]+/ /g; s/^\s+//; s/\s+$//; } printf "%s: %s\n\n" , $auth , $text; $dbh->do('insert into monks values(?,?)', undef, $auth, $text ); }
use warnings; use strict; use Switch; my $dna = 'atctcttttcgtctgctttggggtttgtcctataggcta'; my $base = ''; my @bases = (); my $a = ''; my $c = ''; my $g = ''; my $t = ''; my $err = 0; my $total = 0; calc_base( $dna ); sub calc_base { my ( $dna ) = @_; print 'Please enter a base to calculate: '; chomp( $base = <STDIN> ); @bases = split '', $dna; $total = length $dna; for( @bases ) { ++$a if /a/; ++$c if /c/; ++$g if /g/; ++$t if /t/; ++$err if /[^acgt]/; } switch ( $base ) { case "a" { printf "The amount of adenosine in the sequence is %. +2f%%", ( ($a/$total) * 100); } case "c" { printf "The amount of cytosine in the sequence is %.2 +f%%", ( ($c/$total) * 100); } case "g" { printf "The amount of guanine in the sequence is %.2f +%%", ( ($g/$total) * 100); } case "t" { printf "The amount of thymidine in the sequence is %. +2f%%", ( ($t/$total) * 100); } } }
Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (16)
As of 2015-07-31 14:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (278 votes), past polls