use strict;
my $str = '
<!DOCTYPE html>
<html lang="el" dir="ltr" class="no-js">
<head >
<meta charset="utf-8" />
<title>Radial</title>
<meta name="description" content="Η Radial σχεδιάζει και αναπτÏσσει websites, οÏγανώνει online καμπάνιες και δημιουÏγεί εταιÏικÎÏ‚ ταυτότητες." />
<meta property="fb:page_id" content="118981334805256" />
<meta property="fb:app_id" content="166019300145537" />
<!--[if lt IE 9]><script type="text/javascript" src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<script type="text/javascript">(function(H){H.className=H.className.replace(/\\bno-js\\b/,\'js\')})(document.documentElement);</script>
<link rel="stylesheet" type="text/css" media="screen" href="http://static.radial.gr/styles/screen.css?43614" />
<script type="text/javascript" src="http://use.typekit.com/ioa2dxy.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script?
<link rel="alternate" type="application/rss+xml" title="Τελευταία ÎÏγα" href="/feed/" />
</head>
<body id="home" class="">
<header id="main-header"><div class="wrapper">
<div id="logo"><a href="/"><img src="http://static.radial.gr/images/radial-logo.png" alt="Radial" /></a></div>
<nav id="main-nav">
<ul>
<li><a href="/projects/">ΈÏγα</a></li>
<li><a href="/profile/">Î Ïοφίλ</a></li>
<li><a href="/contact/">Επικοινωνία</a></li>
</ul>
</nav>
<nav id="lang-nav">
<span >EΛ</span>
<a href="/en/">EN</a>
</nav>
<br />
</div></header>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push([\'_setAccount\', \'UA-515952-44\']);
_gaq.push([\'_trackPageview\']);
(function() {
var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;
ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';
var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>
';
my $regex = qr/\<(\w+)(?:\s*\>|\s*\/\>)?/mp;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html