WeeDie has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to merge several .ktf tracks files for Kartex. It's suppose to take the first file in a directory, and append the other files to it, excluding the header.
This is what a .ktf file looks like:I've come up with the following code://Kartex TrackFil skapad av Kartex 5.4 &KTF 2.0,sweref 99 lat long,1 %,0,N59°3.577' E13°2.460',53.97,2009-09-16 10:05:38,,,$ %,1,N59°3.577' E13°2.460',55.89,2009-09-16 10:05:41,,,$ %,2,N59°3.579' E13°2.457',55.41,2009-09-16 10:05:45,,,$ %,3,N59°3.581' E13°2.432',55.41,2009-09-16 10:06:02,,,$ %,4,N59°3.579' E13°2.422',56.37,2009-09-16 10:06:09,,,$ %,5,N59°3.579' E13°2.417',56.37,2009-09-16 10:06:13,,,$
This takes the first line of every file, excluding the header, and merges them into D:\mergedfile.ktf. I was thinking I could add the header to the file later manually. How do I best get it to take everything following the header:use File::Find; my $dir = Cwd::getcwd(); find(\&wanted,$dir); sub wanted { if ($_ != /\.ktf$/) { print "$File::Find::name"; open (GPXDATA, "$File::Find::name") || die("Could not open fil +e! $File::Find::name"); my(@raw_data)=<GPXDATA>; open (MYFILE, '>>D:\mergedfile.ktf'); for (@raw_data) { print MYFILE m"(%,0,.+)"mgs } close (MYFILE); } }
Until the end of the file? And merge it into one file?//Kartex TrackFil skapad av Kartex 5.4 &KTF 2.0,sweref 99 lat long,1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Match multiple lines
by ikegami (Patriarch) on Sep 19, 2009 at 15:25 UTC | |
by repellent (Priest) on Sep 19, 2009 at 16:03 UTC | |
by WeeDie (Novice) on Sep 19, 2009 at 16:27 UTC | |
by repellent (Priest) on Sep 19, 2009 at 18:01 UTC | |
by ikegami (Patriarch) on Sep 20, 2009 at 16:45 UTC | |
by WeeDie (Novice) on Sep 19, 2009 at 15:48 UTC | |
by WeeDie (Novice) on Sep 19, 2009 at 16:09 UTC | |
|
Re: Match multiple lines
by zude (Scribe) on Sep 20, 2009 at 01:00 UTC | |
by Anonymous Monk on Sep 21, 2009 at 11:18 UTC |