in reply to Help to slurp records - $/ maybe?

$/='Field 1:  ' should work, but it doesn't do what you want: $/ is the end-of-line string, which means that with your data the strings will contain:
Update: first line was wrong:
"Field 1:", "abc Field 2: asdfasdf Field 2: asdfasdfase Field 2: aaa Field 3: ss Field 1: ", "def Field 2: abc123 Field 3: blah Field 1: ", "asdfa"
You probably want
while(<FILE>) { next unless /^Field 1/; # ... }
To skip everything but Field 1 lines
-- Joost downtime n. The period during which a system is error-free and immune from user input.

Replies are listed 'Best First'.
Re: Re: Help to slurp records - $/ maybe?
by Limbic~Region (Chancellor) on May 02, 2003 at 13:48 UTC
    Joost,
    I can see how this would work - if you know what the data is you are losing, once you slurp it in you just prepend it back on before processing it.

    I am not sure I want to go this route, but I will keep it in my tool box. I am always looking for neat ways to do things.

    Cheers - L~R

      Well, you're not losing any data (with the $/ trick, that is). The value of the $/ variable is also put at the end of the read 'line'.

      If you want to lose that data, use chomp(), it will remove your current line-terminator.

      The only actual problem is matching the first line.

      -- Joost downtime n. The period during which a system is error-free and immune from user input.
        Since chomp returns the chomped value you could even do something like
        $next_line = chomp($cur_line) . $next_line;
        But I think that's starting to smell like a really dirty hack.

        Makeshifts last the longest.