I needed to make a simple browser user agent parser in Perl. I have found a PHP code that does this but my knowledge is rather limited (esp. in regular expressions). So, here is the code whose Perl equivalent I want to write.
if ($l = ereg($pattern, $agent, $a = array()))
{
array_push($found, array("product" => $a[1], "version" => $a[3], "comment" => $a[6]));
$agent = substr($agent, $l);
}
The $agent is the user-agent string passed as argument, and returns an array of associative arrays $found, each one defining a product/comment in the agent string (key of the associative array are product, version, comment). The $pattern is the user-agent regular expression I am searching which I already know.
So, how would this look like in Perl?
Edit: Seems like there is an confusion about whether I want a Perl compatible regex or an equivalent function in Perl. I am looking for an Perl function and syntax that does the same thing.