Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Modify a txt file

by Eliya (Vicar)
on Oct 20, 2011 at 01:04 UTC ( #932537=note: print w/replies, xml ) Need Help??


in reply to Modify a txt file

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)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://932537]
help
Chatterbox?
LanX gets eaten by a black hole popping up in the vacuum of his head
[Eily]: that a black hole formed there would rather be the sign of a head too full
LanX can't hint anymore to zentaras video because he disappeared

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2017-06-23 16:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (552 votes). Check out past polls.