in reply to Replace arrays in external file
Or use eval("$a[1]$a[0]$a[2]"); It will save you a few keystrokes.
Your program then can become:
use Modern::Perl; while (<DATA>) { do {print; next} unless /^eval/; s/(?<=\[)\d+(?=])/int(rand(99999))/ge; print; } __DATA__ @a = ("'hello world'",'print ', ';'); eval("$a[1]$a[0]$a[2]");
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
My blog: Imperial Deltronics
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Replace arrays in external file
by astroid96 (Initiate) on Apr 10, 2012 at 16:15 UTC | |
by CountZero (Bishop) on Apr 10, 2012 at 20:18 UTC |