home *** CD-ROM | disk | FTP | other *** search
- #!C:/perl/bin/perl
-
- # strip.pl
- ######################################
- # Strip out un necessary text in
- # periodical file & fake an ISBN #
- #
- $file = "periodicals.txt";
- $tempfile = "CARL-index.txt";
-
- sub isbn
- {
- local ($num) = @_;
-
- while (length($num) < 10) {
- $num += int(rand 9999999999);
- }
- return $num;
- }
-
- open (DAT, "< $file") || die "Can't open $file:$!";
- open (TMP, "> $tempfile") || die "Can't open $tempfile:$!";
-
- $flg = 0;
-
- while (<DAT>) {
-
- if (($_ =~ /^\#/) || ($_ =~ /^--/) || ($_ =~ /^\s\s/))
- {
- print TMP $_;
- next;
- }
- if ($_ =~ /Read more about this title/) {next;}
- if ($_ =~ s/(\d+)(\.)(\s*)([^\~]*)(\~)(.*)/$4/)
- {
- $num = $1;
- $isbn = &isbn($num);
- $line = $_;
- chomp($line);
- $flg = 1;
- next;
- }
- if ($flg) {
- if ($_ =~ /([^\/]*)(\/)([^\d]*)(\d*)/) {
- $author = $1;
- $year = $4;
- }
- }
- if ($flg) {
- if ($_ =~ /(Our Price)([^\$]*)(\$)([^\s]*)/) {
- $price=$4;
- $flg = 0;
- $line .= " Author: " . $author . " Published: " . $year;
- $line .= " ISBN: " . $isbn . " Price: " . $price;
- print TMP "$line\n\n";
- }
- }
- }
- close (TMP);
- close (DAT);
- print "done!\n";
-