Skip to content

Instantly share code, notes, and snippets.

@sashaphanes
sashaphanes / fizzBuzz.pl
Created September 26, 2012 16:32
Perl FizzBuzz
#~/usr/bin/perl -w
use strict;
use warnings;
my $count;
for ($count = 1; $count <= 100; $count++) {
if ($count % 15 == 0) {
print "FizzBuzz\n";}
@sashaphanes
sashaphanes / revcomp.pl
Created September 27, 2012 19:53
reversecomplement
my $DNA1 = 'AAATTTTGGGGCCCCaaaaatttttcccccggggg';
my $rev = reverse($DNA1);
my $DNA2 = $DNA1;
$DNA2 =~ tr /atcgATCG/tagcTAGC/;
print "$rev\n";
exit;
@sashaphanes
sashaphanes / openDNAfile.pl
Created September 28, 2012 14:42
openDNAsequence
#!/usr/bin/perl -sw
my $DNAfilename = 'exampleSequence.txt';
open(DNAfile, $DNAfilename);
my $DNA = <DNAfile>;
close DNAfile;
#!/usr/bin/perl
use strict;
use warnings;
print "Which sequence would you like to view?\n\n";
my $DNAfilename = <>;
open(DNAfile, $DNAfilename);
@sashaphanes
sashaphanes / wholeShebang.pl
Created September 28, 2012 15:19
Get user to specify sequence file and print out orginal strand sequence and reverse complementary DNA and RNA
#!/usr/bin/perl
use strict;
use warnings;
print "Which file would you like to use?\n";
my $DNAfilename = <>;
open(DNAfile, $DNAfilename);
@sashaphanes
sashaphanes / guesspasswordpoops.pl
Created October 2, 2012 17:27
Guess a silly password
#!user/bin/perl
use strict;
use warnings;
my $password = 'poops!';
print "Please enter your guess:\n";
my $guess = <STDIN>;
chomp $guess;
@sashaphanes
sashaphanes / motifFinder.pl
Created October 2, 2012 17:32
Open a text file and find a motif in the truncated text found inside
#!/usr/bin/perl
use strict;
use warnings;
my $DNAfilename = 'exampleSequence.txt';
unless (open(DNAFILE, $DNAfilename)) {
print "Could not open file $DNAfilename\n\n";
exit;
@sashaphanes
sashaphanes / transpose.pl
Created October 9, 2012 00:06
Read a whitespace-delimeted text file of columnar data, parse into a matrix, tranpose, and print the result
#!/usr/bin/perl
use warnings;
open FILE, 'practice.txt';
my @content = <FILE>;
print "raw content:\n @content\n\n";
my $line;
@sashaphanes
sashaphanes / variableTransposer.pl
Created October 9, 2012 15:22
flexible transposer
#!/usr/bin/perl
use strict;
#use warnings;
require "getopts.pl";
use vars qw ($opt_f $opt_s $opt_h $opt_H);
&Getopts('f:s:hH:');
@sashaphanes
sashaphanes / tableJoin.pl
Created October 10, 2012 20:21
work in progress...
#!/usr/bin/perl
use strict;
#use warnings;
require "getopts.pl";
use vars qw ($opt_f $opt_s $opt_h $opt_H);
&Getopts('f:s:hH:');