#!/usr/bin/perl # https://perlmonks.org/?node_id=1225199 use strict; use warnings; while( ) { s!\s*\.comm\s+(_\w+),(\d+),(\d+)\n! ".data\n$1:\n" . " .data.32 0\n" x ($2/$3)!e; print; } __DATA__ .comm _resultAvg,8,4 .comm _resultSwap,8,4 .comm _resultMax,20,4