Karen Medina's place to put stuff that doesn't belong anywhere else

I-Vote: An Audience Voting System (CHI2004 Student Design Competition)

my greenstone installation: standard demo, behind the scenes.

Some basic cgi help for those who asked for it :

Microsoft Game for LIS450cw:

GSLIS student life :

Information Seeking in Context I

Information Seeking in a Common Task/Form Usability Study, UIUC IRB number 03264

Information Seeking in Context II

Old projects

My old assistantships :

Links to my home pages

Perl Help Notes

Installing Perl Modules When You Aren't Root

  0 cd /home/username/bin/perl-lib/
  1  wget http://search.cpan.org/CPAN/authors/id/M/MS/MSERGEANT/XML-XPath-1.13.tar.gz
  2  tar -xvzf XML-XPath-1.13.tar.gz
  3  ls
  4  cd XML-XPath-1.13
  5  perl Makefile.PL PREFIX=/home/username/bin/perl-lib
  6  ls
  7  cd XML-XPath-1.13
  8  make && make test
  9  make install PREFIX=/home/username/bin/perl-lib
  10 history > install_commands.txt

#!/usr/bin/perl -w
use lib('/home/username/bin/perl-lib/')
use XML::XPATH;
print "Just testing\n";
find /home/username/ -name Templates.pm

Regular Expressions

(this webpage is helpful)
*Match 0 or more times
+ Match 1 or more times
? Match 1 or 0 times
{n} Match exactly n times
{n,} Match at least n times
{n,m} Match at least n but not more than m times

Things I tend to forget the syntax for:

Sorting a hash on the value (and printing it to a text file)

sub print_hash {
    my $output = pop(@_);
    my %hash = @_;
    open(OUT, ">$output")|| die "Could not open output file: $output.\n";
    print "Output file is $output\n";
    foreach $k (sort { $hash{$b} cmp $hash{$a} } keys %hash) {
       print OUT "$k => $hash{$k}\n";
    }# end foreach
    close(OUT);
}# end sub print_hash

Sort hash by key

sub print_hash {
    my $output = pop(@_);
    my %hash = @_;
    open(OUT, ">$output")|| die "Could not open output file: $output.\n";
    print "Output file is $output\n";
    foreach $k (sort keys %hash) {
        print OUT "$k => $hash{$k}\n";
    }# end foreach
    close(OUT);
}# end sub print_hash

&get_todays_date -- A sub I wrote (and tend to reuse) to get todays date and append it to a file name.

$suffix = &get_todays_date();
$new_file_name = $start_of_file_name . '_' . $suffix . '.txt';
sub get_todays_date {
    my ($year, $mon, $day, $hour, $min) = (localtime)[5,4,3,2,1]; #system ("date");
    $year += 1900;
    $mon += 1;
    if ($mon < 10){ #added Feb 19, 2004 by Karen Medina
        $mon = '0'. $mon;
    }# end if
    my @date = ($year, $mon, $day, $hour, $min);
    my $date = join('_', @date);
    return $date;
}# end sub

more perl notes


gslis,uiuc Graduate School of Library and Information Science an image of the words University of Illinois at Urbana-Champaign an image of the words Graduate School of Library and Information Science
Maintained by: webmaster
Comments to: Karen Medina
Last modified: Monday, 11 October, 2004, 17:51