#!/usr/bin/perl # http://perlmonks.org/?node_id=1193751 use strict; use warnings; use Path::Tiny; my %hash = map /^("\w+"),("\w+")/, path('file2.txt')->lines; my $pattern = do { local $" = '|'; qr/@{[ keys %hash ]}/ }; path('file1.txt')->edit_lines( sub { s/^($pattern).\K"\w+"/$hash{$1}/ +} );
In reply to Re: Replace value in the text file
by tybalt89
in thread Replace value in the text file
by mhoang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |