#!/usr/bin/perl use warnings; use strict; my $input_file = 'dump.vcd'; open (INPUT, '<', $input_file) or die $!; while () { s/\$var\w \d+ ([!,\#,\",\$,\%,&]) (\w) \$end/\$var $1 $2/; print; } close INPUT;