CSV("|" 区切り BSV)用 perl プログラム |
#!/usr/local/bin/perl -w # Usage: check bsv-file名: すべてのレコードの field 数を最初の field 数と比較 use strict; $#ARGV == 0 || die "Usage: check filename.b\n"; $_ = <>; my @data = split(/\|/, $_,100); my $nf = $#data; print; printf("number of fields=%d\n", $#data + 1); my $nr = 1; while(<>) { $nr++; @data = split(/\|/, $_, 100); if($#data != $nf) { printf("number of flds=%d\n", $#data + 1); print; } } print "number of data=$nr\n"; |
#!/usr/local/bin/perl -w # Usage: b.sort fldnumber-of-sort-key file use strict; my $fld = shift || die "Usage: b.sort fldnumber-of-sort-key(1-) [filenames]\n"; $fld--; print $_ = <>; my @data = <>; print sort byFld @data; sub byFld { (split(/\|/, $a))[$fld] cmp (split(/\|/, $b))[$fld]; } |
#!/usr/local/bin/perl my ($first); print <<EOF; <html lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=euc-jp"> <head> <body bgcolor="#203040" text="#f0f0f0" link="#a0f0f0" vlink="#f0a0f0" alink="#f000f0"> <center> EOF $_=<>; chomp; $ltime = localtime; print "<h2>$_</h2> <h4>Last update on $ltime</h4> <h4>Since 1998</h4> </center> <hr size=5> <dl> "; $_ = <>; $first = 1; while (<>) { if ($first == 1) {print "<dt>$_"; $first = 0;} else {print "<dd>$_";} if ($_ eq "\n") {$first = 1; print "</dl>\n<dl>";} } print <<EOF; </dl> <hr> <address> Y. Okabe / The Univ. of the Air<br> </address> </body> EOF |
status(from 86)|Key|敬称 |
#!/usr/local/bin/perl -w # Usage: b.join bsv-file名: bvs-file のデータへ ../addr.b のデータを統合する use strict; #$#ARGV == 0 || die "Usage: b.join filename.b\n"; $,="\|"; open(ADDR, '< ../addr.b'); while(<>) { chomp; my ($state, $key, @memo) = split(/\|/, $_); while (<ADDR>) { my ($key_, @data_) = split(/\|/, $_); if ($key_ eq $key) {print $state, $key, @memo, @data_; last;} } } |
#!/usr/local/bin/perl -w # Xmas、年賀状用ラベルの platex file 作成プログラム: NYlabel join > label.tex # join: b.join select > join で作ったファイル # この後、platex temp.tex #$#ARGV == 0 || die "Usage: NYlabel join > temp.tex\n"; @pos = ('5mm,27mm','75mm,27mm','145mm,27mm', '5mm,69.3mm','75mm,69.3mm','145mm,69.3mm', '5mm,111.6mm','75mm,111.6mm','145mm,111.6mm', '5mm,153.9mm','75mm,153.9mm','145mm,153.9mm', '5mm,196.2mm','75mm,196.2mm','145mm,196.2mm', '5mm,238.5mm','75mm,238.5mm','145mm,238.5mm'); print '\documentclass[a4paper]{jarticle} \usepackage{/usr/home/okabe/usr/tex/packages/at} \begin{document} \pagestyle{empty} % '; $_ = <>; $i = 0; print "{\\sf \n"; while (<>) { chomp; ($state, $key, $title, $date, $name, $otitle, $cell, $h_addr, $h_tel, $h_email, $o_addr, $o_tel, $o_email) = split(/\|/, $_); if ($h_addr) {$addr = $h_addr;} else {$addr = $o_addr;} # if no home_address $addr =~ s/\%/\\\\\n/g; # % → CR $addr =~ s/\&/\\&/g; # & → \& $addr =~ s/\#/\\#/g; # # → \# if ($title =~ /^[A-Za-z]/) { # English title if ($name =~ /^[A-Za-z]/) { # if name is also English $name = "$title $name"; } else { $name = $title; } else { # Kanji title $name = "$name $title"; } $name =~ s/\%/\\\\\n/g; $name =~ s/\&/\\&/g; $name =~ s/\#/\\#/g; print '\\at(', $pos[$i], '){\parbox[t]{75mm}{'; if ($title =~ /^[A-Za-z]/) { # English label print "{\\large $name}\\\\\n\ \\\\\n$addr}}\n"; } else { # Kanji label print "{\\large $addr}\\\\\n\ \\\\\n{\\Large $name}}}\n"; } $i++; if ($i == 18) {$i = 0; print "\\newpage\n %\n";} } print "\\newpage\n"; print "}\n"; print "\\end{document}\n"; |