use strict;
my $str = '<?xml version="1.0" encoding="UTF-8"?>
-<Devices-Detail-Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.embeddeddatasystems.com/schema/owserver">
<PollCount>71</PollCount>
<DevicesConnected>2</DevicesConnected>
<LoopTime>2.048</LoopTime>
<DevicesConnectedChannel1>2</DevicesConnectedChannel1>
<DevicesConnectedChannel2>0</DevicesConnectedChannel2>
<DevicesConnectedChannel3>0</DevicesConnectedChannel3>
<DataErrorsChannel1>0</DataErrorsChannel1>
<DataErrorsChannel2>0</DataErrorsChannel2>
<DataErrorsChannel3>0</DataErrorsChannel3>
<VoltageChannel1>4.81</VoltageChannel1>
<VoltageChannel2>4.81</VoltageChannel2>
<VoltageChannel3>4.80</VoltageChannel3>
<VoltagePower>5.05</VoltagePower>
<DeviceName>OWServer_v2-Enet</DeviceName>
<HostName>EDSOWSERVER2</HostName>
<MACAddress>00:04:A3:BE:A9:F2</MACAddress>
<DateTime>2017-03-10 23:18:40</DateTime>
-<owd_DS18B20 Description="Programmable resolution thermometer">
<Name>DS18B20</Name>
<Family>28</Family>
<ROMId>690516B3FC14FF28</ROMId>
<Health>7</Health>
<Channel>1</Channel>
<RawData>54014B467FFF0C10FDFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</RawData>
<PrimaryValue>21.2500 Deg C</PrimaryValue>
<Temperature Units="Centigrade">21.2500</Temperature>
<UserByte1 Writable="True">75</UserByte1>
<UserByte2 Writable="True">70</UserByte2>
<Resolution>12</Resolution>
<PowerSource>255</PowerSource>
</owd_DS18B20>
-<owd_DS18B20 Description="Programmable resolution thermometer">
<Name>DS18B20</Name>
<Family>28</Family>
<ROMId>020316B4A6C3FF28</ROMId>
<Health>7</Health>
<Channel>1</Channel>
<RawData>55014B467FFF0C10BEFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</RawData>
<PrimaryValue>21.3125 Deg C</PrimaryValue>
<Temperature Units="Centigrade">21.3125</Temperature>
<UserByte1 Writable="True">75</UserByte1>
<UserByte2 Writable="True">70</UserByte2>
<Resolution>12</Resolution>
<PowerSource>255</PowerSource>
</owd_DS18B20>
</Devices-Detail-Response>';
my $regex = qr/<RawData>55014B467FFF0C10BEFF00+<\/RawData>\n\n<PrimaryValue>(\d+.\d+)/p;
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