in reply to Re^2: Match multiple lines
in thread Match multiple lines

Yes exactly. The header is the 2 first lines of each file.

I want a script that takes all lines following the header, from all .ktf files in the current directory, and merges them into one file, ultimately with the header added to it.

I'm sorry, I don't understand the $fh_in and $fh_out variables. This is my first perl script >_<

If someone could give me a more detailed reply on how to read and merge all lines following the 2 first lines, in all .ktf files in a directory, and write it to a file, I would be eternally grateful! :)

Replies are listed 'Best First'.
Re^4: Match multiple lines
by repellent (Priest) on Sep 19, 2009 at 18:01 UTC
    WeeDie, did you try the solution provided by ikegami at the end of his post?

    Then try substituting the find() call with the one in my post?

    Please state how those solutions differ from your expectations.

    The $fh_in and $fh_out are filehandle variables, much like MYFILE in your OP. Since you're new to Perl, you can think of those filehandle variables as another way to write GPXDATA and MYFILE, respectively.

    Oh, and welcome to Perl! :)
Re^4: Match multiple lines
by ikegami (Patriarch) on Sep 20, 2009 at 16:45 UTC

    I'm sorry, I don't understand the $fh_in and $fh_out variables.

    You used global vars GPXDATA and MYFILE. I switched to using lexical vars with more meaningful names: $fh_in and $fh_out. ("fh" stands for "file handle".)

    If someone could give me a more detailed reply on how to read and merge all lines following the 2 first lines, in all .ktf files in a directory, and write it to a file, I would be eternally grateful! :)

    I don't know how we can get more detailed then providing the code that does that.