use strict;
my $str = 'm_dwErrorCode = 0;
m_dwOutError = HOP_OK;
m_OutSeverity = CCC_INFORMATION;
_stprintf(m_OutDevStr, _T(""));
if (0x00000000 & value)
{
m_dwErrorCode = 0x0;
/* Ready state. */
// m_StatusStr = " Ready(eSTATUS_READY)";
}
if (0x00000001 & value)
{
m_bProceeding = true;
/* proceed */
//m_StatusStr = " Proceeding(eSTATUS)";
}
if (0x00002000 & value)
{
m_bEmpty = true;
// We only want to check this error only at certain times.
if (m_bCheckEmpty)
{
if ((m_Attributes.dwMediaID == CUBE1) ||
(m_Attributes.dwMediaID == CUBE2) ||
/*(m_Attributes.dwMediaID == SCALLOPED) ||*/ // Added
(m_Attributes.dwMediaID == FOLDED))
{
m_dwErrorCode = 0x00002000;
_stprintf(m_OutDevStr, _T("0x1000 - %s(MP Tray Empty)"), errorStr);
m_dwOutError = HOP_TRAY_EMPTY;
m_OutSeverity = CCC_INFORMATION;
}
}
//HOP_TRAY_EMPTY
///* MSI empty. */
//m_bTrayEmpty = true;
//// m_StatusStr = " MSI empty(eSTATUS_MSI_EMPTY)";
}
if (0x00004000 & value)
{
/* empty. */
m_dwErrorCode = 0x4000;
_stprintf(m_OutDevStr, _T("0x4000 - %s(Tray 1 empty)"), errorStr);
m_dwOutError = HOP_TRAY_01_EMPTY;
m_OutSeverity = CCC_INFORMATION;
}
if (0x00008000 & value)
{
/* Tray 2 empty. */
m_dwErrorCode = 0x8000;
_stprintf(m_OutDevStr, _T("0x8000 - %s(Tray 2 empty)"), errorStr);
m_dwOutError = HOP_TRAY_02_EMPTY;
m_OutSeverity = CCC_INFORMATION;
}
if (0x00010000 & value)
{
/* Tray 3 empty. */
m_dwErrorCode = 0x10000;
_stprintf(m_OutDevStr, _T("0x10000 - %s(Tray 3 empty)"), errorStr);
m_dwOutError = HOP_TRAY_03_EMPTY;
m_OutSeverity = CCC_INFORMATION;
}';
my $regex = qr/(?si)m_dwErrorCode\s*=\s*(?<code>\dx\d+);\s*_stprintf\(.*?\(.*?\((?<description>.*?)\).*?;\s*m_dwOutError\s*=\s*(?<error>[\w_]+);\s*m_OutSeverity\s*=\s*(?<severity>[\w_]+)/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