in reply to Re^2: re-ordering lines of text in a file?
in thread re-ordering lines of text in a file?
If you need to create a separate record for each value then try
poj#!perl use strict; use DBI; use Text::ParseWords 'quotewords'; open OUT,'>','output.txt' or die "$!"; my @infiles = glob("*.odf"); for my $infile (@infiles){ open IN,'<',$infile or die "Could not open $infile : $!"; print "Reading $infile.."; my $count=0; while (<IN>){ chomp; ++$count; my ($key,$string) = split /\s*=\s*/,$_; my @values = quotewords('\s+',0,$string); for my $i (1..@values){ printf OUT "%-30s %-35s %-35s %5d\n", $infile,$key,$values[$i-1],$i; } } print "$count lines read\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: re-ordering lines of text in a file?
by moddingforfun (Initiate) on Dec 02, 2016 at 14:26 UTC |