Hi Ryanjohns,
I'm not a coder, I've never coded anything before, and I've been trying to teach myself specifically for this little project.
In that case, beginning with perlintro is probably the best first step. It will show you many of the basics, including how to open a file and loop over its lines. (However, I'm wondering about the code you posted in this reply, it looks like you've gotten past the basics?)
This is one of those cases where first describing how you might solve the problem without code will probably help. If you're reading a file line-by-line, which makes sense if the input is large, note that normally each line read ends in a newline character, which you'd use chomp to remove. That'd be your input. Regular expressions, which would help you decide whether a line begins with a number, are described e.g. in perlretut.
Now as for the concatenation, in Perl There Is More Than One Way To Do It (TIMTOWTDI), and it depends on how you want to accumulate the lines.
If you don't want to accumulate the lines at all, you could simply print them back out, choosing to append a newline character \n only when appropriate.
Or, you could store the lines in an array, using the push function to add them, outputting the elements of that array with the help of a loop or the join function, and then clearing that array every time you start a new set of lines.
Or, you could accumulate the lines by appending them to a string, using the concatenation operator . (dot), described in perlop.
In all three cases, you'll need to decide when you want the output to start a new line and when not (when to output the currently accumulated lines and clear the array or string). Note that if you use the condition "this line starts with a number" for outputting the previously accumulated lines, then you'll need to cover the case of the last lines read, since there's no following line to trigger the output, so you could handle that e.g. by adding one more output statement after the loop.
Hope this helps,
-- Hauke D
In reply to Re: Gentleman, I'm lost.
by haukex
in thread Gentleman, I'm lost.
by Ryanjohns
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |