in reply to split paragraph

Just use my($needed_data)= /data_here(.+)/. See perlop on Regexp-Quote-Like Operators. There it is explained how to use the match operator in list context and what it returns.

Replies are listed 'Best First'.
Re^2: split paragraph
by james28909 (Deacon) on Nov 02, 2014 at 21:48 UTC
    well i tried that, but it matched for some reason the beginning of the paragraph to the first newline char. say for instance i have:

    firstline
    secondline
    data_hereDATA

    the pattern "data_here" goes into $temp, and $needed_data is actually "DATA";
    if i wanted "DATA" but didnt know "DATA" was going to be "DATA" and could have been "abc" or "a1dhiud76", the regex i posted above (which i will need to go back and explain further in detail now that i think about it) will match everything AFTER "data_here" until new line char... which returns "DATA" or any other values/characters to $needed_data. im trying to do that without having to spend that extra variable.

    the solution given earlier wont work for some reason tho undef does. correction what corion said did indeed work. i was still trying to split for some reason. after removing the "split" from the function it works. thanks

      I'm sorry, but without seeing your code, and your data, the output you get and the output you want, I can't really help you there.

      Maybe you can explain things better if you post real, runnable code and data for that program, because for me, the following just works as I imagine it should:

      #!perl -w use strict; my $data= <<EOM; firstline secondline data_hereDATA THAT IS CAPTURED EOM $_= $data; my($result)= /^data_here(.+)/m; print $result; # DATA THAT IS CAPTURED
        ah ok, i see now. for some reason when i use "split(/^any_pattern(.+)/m)" it fails, btu when doing it like you showed it worked flawless. thanks. i will update the post in cool uses for perl