in reply to split, manipulate, join

This will capture everything after "ekey=" all the way up to new line
(undef, $captured) = split(/ekey=(.+)/, $_);

Replies are listed 'Best First'.
Re^2: split, manipulate, join
by AnomalousMonk (Archbishop) on Apr 12, 2015 at 07:14 UTC

    I think I would rather explicitly extract whatever it was I was interested in rather than relying on a somewhat obscure feature of the split built-in:

    c:\@Work\Perl\monks>perl -wMstrict -le "$_ = qq{xxx ekey=foo bar \n xyzzy}; ;; my (undef, $captured) = split(/ekey=(.+)/, $_); print qq{captured '$captured'}; ;; my ($bagged) = $_ =~ m{ ekey= ([^\n]+) }xms; print qq{ bagged '$bagged'}; " captured 'foo bar ' bagged 'foo bar '


    Give a man a fish:  <%-(-(-(-<