in reply to Extract hidden values from HTML

With the clarification in "Re 3", this should give you an approach:

#!/usr/bin/perl use strict; use warnings; # 812662 my @data = ('<td class="c"><input type="hidden" name="recid5" value="1 +0293424">2009/08</td>', '<td class="c">foobar - Item &quot;123&quot;: <b>8</b></td +>' ); for my $data(@data) { if ($data =~ /"hidden"/ && $data =~ /value="([^"]+)/ ) { print "Hidden value: $1 \n"; }else{ print "Nothing hidden in \$data: $data\n"; } }

Output:

Hidden value: 10293424 Nothing hidden in $data: <td class="c">foobar - Item &quot;123&quot;: +<b>8</b></td>

Update: else {...} added for clarity and output updated