#!/usr/local/bin/perl ### wants perl5 ## a hack to order the entries by inv no before they go into the ## database, this saves computing at the output end (at least with ## opentext indexers, results will vary...) ## i'm presuming that each entry is on a line by itself, recently come ## from fmpro... ## i seem to have three kinds of inventory numbers, simple numbers, ## P.Mich.inv. number, and O.mich.inv. numbers, i'll put out each of ## these three in that order, with numbers sorted in each chunk, and ## finally the leftovers that didn't fit into the above. while (<>) { chomp; m,,i; my($invno) = lc($1); # lc it for sorting... $invno =~ s,\s+,,g; # get rid of whitespace irregularities # entirely for sorting... ## in the below, i append instead of merely assigning because ## apparently the michigan catalog permits records with identical ## inventory numbers... if ($invno =~ m,^\d+$,) { $digitsonly{$invno} .= $_; } elsif ($invno =~ m,^p\.mich\.inv\.?\d*$,) { $pmich{$invno} .= $_; } elsif ($invno =~ m,^o\.mich\.inv\.?\d*$,) { $omich{$invno} .= $_; } else { $allotherspaycash{$invno} .= $_; } } foreach $item (sort { $a =~ m,(\d+),; $a1 = $1; $b =~ m,(\d+),; $b1 = $1; $a1 <=> $b1; } (keys (%digitsonly))) { print($digitsonly{$item}, "\n"); } foreach $item (sort { $a =~ m,(\d+),; $a1 = $1; $b =~ m,(\d+),; $b1 = $1; $a1 <=> $b1; } (keys (%pmich))) { print($pmich{$item}, "\n"); } foreach $item (sort { $a =~ m,(\d+),; $a1 = $1; $b =~ m,(\d+),; $b1 = $1; $a1 <=> $b1; } (keys (%omich))) { print($omich{$item}, "\n"); } foreach $item (sort (keys (%allotherspaycash))) { print($allotherspaycash{$item}, "\n"); }