chewtoy has asked for the wisdom of the Perl Monks concerning the following question:
/dev/hda5 303344 99042 188641 35% /
Basically, I want to take anything that matches this: m/ (\d+) /
...and do something to it (ie divide by 1024), then stick it back in where it was. It would be nice to be able to do this with perl -pe 'something', but I can't even figure out how to do it at all - how do I match once on a line, change something, then start matching again after the spot I changed on the same line?
For example, let's assume I wanted to take every big number i see in my input and turn it into that number divided by 1000. How do I do that?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: One-liner (or few-liner) for massaging regexps?
by japhy (Canon) on Sep 17, 2002 at 18:03 UTC | |
|
Re: One-liner (or few-liner) for massaging regexps?
by RMGir (Prior) on Sep 17, 2002 at 17:50 UTC | |
by Aristotle (Chancellor) on Sep 17, 2002 at 21:28 UTC | |
|
Re: One-liner (or few-liner) for massaging regexps?
by sauoq (Abbot) on Sep 17, 2002 at 17:44 UTC | |
|
Re: One-liner (or few-liner) for massaging regexps?
by Aristotle (Chancellor) on Sep 18, 2002 at 07:05 UTC | |
by sauoq (Abbot) on Sep 18, 2002 at 14:12 UTC |