srsahu75 has asked for the wisdom of the Perl Monks concerning the following question:
Kindly help me in modifying the script to proceed furtherInput file: Thu Mar 19 2:34:14 EDT 2009 STC Data query: Record 1 of 1 DN: Data Name Information Sciences TI: Title Distribution and abundance of bound volumes of the file in institute shelves from 1978 AU: Author Sahu, SR; Gawas, AKG AF: Affiliation Inst. of document scanning and documentation profiling at library, toward the prograssive society and establishment SO: Source Test document file. Vol. 5, no. 1, pp. 1-14. Jul 1990. DE: Descriptors Article Subject Terms: Abundance; Ecological distribution; Geographical distribution; Life cycle; Zooplankton; Article Taxonomic Terms: Euphausia; Article Geographic Terms: ISW, LA: Language English Perl Script: #!/usr/bin/perl -w my $found_f = 0; my ($lastline, $line); open (INPUTFILE, "test.txt"); while (<INPUTFILE>) { chomp; if (/^[A-Z]{2}:\s/) { $lastline = $line; $line = $_; $found_f = 1; } elsif (! /^[A-Z]{2}:\s/ && $found_f) { s/^ {4}/ /; $line .= $_; next; } elsif (/^$/) { $lastline = ' '; $found_f =0; } print "$lastline\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need help to make correction in a perl script
by ig (Vicar) on Mar 20, 2009 at 10:25 UTC | |
by srsahu75 (Initiate) on Mar 20, 2009 at 11:18 UTC | |
by ig (Vicar) on Mar 20, 2009 at 18:50 UTC | |
by gokuraku (Monk) on Mar 20, 2009 at 13:15 UTC | |
|
Re: Need help to make correction in a perl script
by cdarke (Prior) on Mar 20, 2009 at 10:09 UTC | |
by srsahu75 (Initiate) on Mar 20, 2009 at 11:13 UTC | |
|
Re: Need help to make correction in a perl script
by missingthepoint (Friar) on Mar 20, 2009 at 10:16 UTC | |
|
Re: Need help to make correction in a perl script
by bichonfrise74 (Vicar) on Mar 20, 2009 at 16:16 UTC |