in reply to Re: Returning Line where Characters Have been found
in thread Returning Line where Characters Have been found

Hi TJ, thanks for your ideas here, but sadly i am a bit too stupid to understand what you have written there, i a struggling with the < DATA > part ..
  • Comment on Re^2: Returning Line where Characters Have been found

Replies are listed 'Best First'.
Re^3: Returning Line where Characters Have been found
by cavac (Prior) on Dec 13, 2011 at 15:42 UTC

    The __DATA__ segment at the end of the file stores data in what Perl interpretes as some sort of pseudo-file. To read that out, you can use the filehandle DATA.

    What TJPride does here is reading out all the lines as array and joining them into a single string. (Reading from < DATA > in array context since it is the array argument to join).

    BREW /very/strong/coffee HTTP/1.1
    Host: goodmorning.example.com
    
    418 I'm a teapot
Re^3: Returning Line where Characters Have been found
by TJPride (Pilgrim) on Dec 13, 2011 at 19:29 UTC
    my $cmdout = join '', <DATA>; is the same as if I just put all the stuff below the __DATA__ line into $cmdout directly. It's also the same as if I had that data in a file, opened a filehandle to it (let's say FH) and then read it using my $cmdout = join '', <FH>;. Basically, __DATA__ is just a good way to post code examples without having to exclude the file data it's running on.