You are on page 1of 2

Details of practice with new tool/technology (max 2 pages)

Perl
We learned this new language during the course of the project. Following are the few code snippets we created while learning this language.
#!/usr/bin/perl use strict; #my $what = 'fred'; my $what = "fred|barney"; while(<>) { if( /(?:$what){3}/x ) { print "Matched : [$&]\n"; } else { print "Not Matched\n"; } }

#!/usr/bin/perl use strict; my $in_filename = $ARGV[0]; my $out_filename =$in_filename.".out"; if( ! defined $in_filename ) { die("Very less parameters passed"); } open IN , "<" , $in_filename or die ("Unable to open file for reading : $!"); open OUT , ">" , $out_filename or die ("Unable to open file : $!"); while(<>) { s/fred/Larry/gi; print OUT $_; } #!/usr/bin/perl use strict; while (<>) { chomp; if (/match/) { print "Matched: |$`<$&>$'|\n"; } else { print "No match: |$_|\n"; } } #!/usr/bin/perl use strict; while (<>) { chomp; if (/a\b/x) { print "Found a word ending with 'a'\n" } else { print "NO word found\n"; } }

R
nysalaries = c(33750, 44000, 138188, 45566.67, 44000, 141666.67, + 292500, 5600000, 103500, 190000, 65000, 33750, 195000, 44000.04, + 4600000, 194375, 33750, 112495.5, 95000, 301999, 181500, 33750, + 185000, 205000, 44000); nysalaries = sort(nysalaries) nysalariesTrim = nysalaries[3:23] mean = mean(nysalaries) median = median(nysalaries) range = max(nysalaries)-min(nysalaries) IQR = IQR(nysalaries) std = sd(nysalaries) original = c(mean, median, range, IQR, std) meanTrim = mean(nysalariesTrim) medianTrim = median(nysalariesTrim) range = max(nysalariesTrim)-min(nysalariesTrim) IQR = IQR(nysalariesTrim) std = sd(nysalariesTrim) trim = c(meanTrim, medianTrim, range, IQR, std) stats = cbind(original, trim) rownames(stats) = c("Mean", "Median", "Range", "IQR", "SD") patientID <- c(1, 2, 3, 4) age <- c(25, 34, 28, 52) diabetes <- c("Type1", "Type2", "Type1", "Type1") status <- c("Poor", "Improved", "Excellent", "Poor") patientdata <- data.frame(patientID, age, diabetes, status) sink("output.log",append = TRUE, split = TRUE) x <- runif(50) plot(x,x)

You might also like