One way to do it:
#!/usr/bin/perl -w use strict; local $/ = ""; # paragraph mode while (<DATA>) { my ($num) = /^(\d+)/; s/\w+/$num/g; print; } __DATA__ 0 ASDF ASEE ASEE 13 DERG DREG 28 QWER QWER 42 WERT WERT WERT 55 QWEASD QWEASD QWEASD QWEASD
(note that $/ = "" is not the same as $/ = undef, see perlvar)
In reply to Re: Modify a txt file
by Eliya
in thread Modify a txt file
by la
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |