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:
//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,,,$
I've come up with the following code:
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); } }
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:
//Kartex TrackFil skapad av Kartex 5.4 &KTF 2.0,sweref 99 lat long,1
Until the end of the file? And merge it into one file?

In reply to Match multiple lines by WeeDie

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.