my @arr = 1 .. 20; my @excludes = (1,3,5,7,9,11,13,15,17,19); @arr[@excludes] = (); @arr = grep $_, @arr; print join(" : ", @arr)."\n"; #### use DBI; #connect and stuff. create the DB handle my %hash = ( 'col1'=>$somevalue, 'col2'=>$someothervalue, 'col3'=>$yav); my $sql = qq~INSERT INTO table1(~ . join(',', sort keys %hash). qq~) VALUES(~. join(',',(('?') x scalar( keys %hash))). qq~)~; my $sth = $dbh->prepare($sql); $sth->execute(@hash{(sort keys %hash)}); #### #!/usr/bin/perl -w use strict; use POSIX qw/ceil/; use Data::Dumper; my %bases = ('a'=>[0,0], 'c'=>[0,1], 'g'=>[1,0], 't'=>[1,1]); my %bvals = ('00'=>'a', '01'=>'c','10'=>'g','11'=>'t'); my $DNA = 'acgtagattaatcgagctagcctgatgcgatcgatcgagagggtctctttattctgatcgatcgcgctagatagcgatcgatcgatcgatacacagttataacagagtcttatatca'; my $DNA_frag1 = 'gatc'; my $DNA_frag2 = 'gcct'; sub DNA_pack { my $instr = shift; my $vt = 0 x ceil(length($instr)/4); my $mo = length($instr) * 2; my @c = split(//,$instr); my $bi = 0; while(my $c = shift(@c)){ my @b = @{$bases{$c}}; vec($vt, $bi, 1) = shift @b; vec($vt, $bi+1, 1) = shift @b; $bi += 2; } return [$mo,$vt]; } sub DNA_unpack { return join('',(map{m/\d\d/?$bvals{$_}:()}split(/(\d\d)/,unpack("b$_[0]->[0]",$_[0]->[1])))); } #### "Oranges and lemons", say the bells of St. Clement's "You owe me five farthings", say the bells of St. Martin's "When will you pay me?" say the bells of Old Bailey "When I grow rich", say the bells of Shoreditch "When will that be?" say the bells of Stepney "I do not know", says the great bell of Bow Here comes a candle to light you to bed And here comes a chopper to chop off your head! Chip chop chip chop - The last man's dead. #### sub vector_diff { my $input = shift || return 0; my @output; for(1 .. $#{$input}){ push @output, ($input->[$_] - $input->[$_-1]); } return @output; }