in reply to Re^2: Regex for multiple numbers between double quotes
in thread Regex for multiple numbers between double quotes

Did you look at my previous suggestion regarding the "g" regex modifier? Here's how to use it:

#!/usr/bin/env perl use strict; use warnings; open (my $original, '<', 'data.txt') or die $!; open (my $fh, '>', 'output.txt') or die $!; my $first = <$original>; print $fh $first; my @replace = $first =~ /"([^"]*)"/g; while (my $line = <$original>) { $line =~ s/(\d{2})/$replace[$1]/g; print $fh $line; } close $original; close $fh;

Is that concise enough for you?

Replies are listed 'Best First'.
Re^4: Regex for multiple numbers between double quotes
by Akatsuki (Novice) on Oct 12, 2016 at 09:55 UTC

    Thank you very much, this is exactly what I needed. God bless you!