http://qs321.pair.com?node_id=11100688


in reply to search and replace desired portion from a line

Hello syedasadali95,

I suppose you want to match any single integer from 0-9 after addr:0x*? If this is the case why not simply like:

$line1 =~ s/addr:0x[0-9]/addr:$address/;

Also there is no need to escape semicolon character. :)

Update: Fellow Monk AnomalousMonk has a point. This is the more correct solution $line1 =~ s/addr:0x[[:xdigit:]]+/addr:$address/;. Since this a hex value and not just a digit.

Hope this helps, BR.

Seeking for Perl wisdom...on the process of learning...not there...yet!