in reply to Perl to collect "Link" values contains "next"

Corion's approach is the correct one. However, since you asked using a regex on the string and have still not shown that you have learned How to ask better questions using Test::More and sample data, here is one final demonstration.

use strict; use warnings; use Test::More tests => 1; my $response1 = <<EOT; Cache-Control: no-cache, no-store Connection: close Date: Fri, 26 Mar 2021 02:11:16 GMT Pragma: no-cache Server: nginx Vary: Accept-Encoding Content-Type: application/json Expires: 0 Client-Date: Fri, 26 Mar 2021 02:11:16 GMT Client-Peer: 10.10.1.32:8080 Client-Response-Num: 1 Client-Transfer-Encoding: chunked Expect-Ct: report-uri="https://org.extract.net", max-age=0 Link: <https://sso.myorg.com/api/v5/myids?limit=200>; rel="self" Link: <https://sso.myorg.com/api/v5/myids?after=200xxxxxxxxxxxxxxxxx&l +imit=200>; rel="next" EOT my $want = '<https://sso.myorg.com/api/v5/myids?after=200xxxxxxxxxxxxx +xxxx&limit=200>; rel="next"'; my @linkheader = $response1 =~ /^Link: (.*"next")/mg; is $linkheader[0], $want;

🦛

Replies are listed 'Best First'.
Re^2: Perl to collect "Link" values contains "next"
by parv (Parson) on Mar 27, 2021 at 01:06 UTC

    Frankly my reply is not receiving enough negative votes as it was not directly related, and might have sent OP chasing red herrings. Come on, people!