drewman08 has asked for the wisdom of the Perl Monks concerning the following question:
I am a newbie to Perl, and am trying to use a simple script to read from one file and write to another. The file I am reading from has two text strings that very in length (many iterations) and I think the problem lies in my regex as all I can get it to do is write "1" on two lines (minus the "") Can you help?
TIA
here is an example of the two text strings that vary in length
points: "_eglErdrm@}}vA|}vAihtB~}vAik{C|}vA}~mHnojBgzlBjy[aktAoeAooo@_l`@wl^y{oA",
levels: "PKLMOKNLP",
Here is my code so far..
open(FILEREAD, "< read.js") or die "Cannot open FILEREAD:$!"; open(FILEWRITE, "> write.js") or die "Cannot open FILEWRITE:$!"; while (<FILEREAD>){ $points = s//(points)+.,/; $levels = s//(levels)+.,/; print FILEWRITE "$points\n"; print FILEWRITE "$levels\n"; } close FILEWRITE; close FILEREAD;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex question
by jwkrahn (Abbot) on Jul 04, 2008 at 15:21 UTC | |
by toolic (Bishop) on Jul 04, 2008 at 15:32 UTC | |
|
Re: Regex question
by graff (Chancellor) on Jul 04, 2008 at 15:23 UTC | |
by drewman08 (Initiate) on Jul 05, 2008 at 10:45 UTC | |
by drewman08 (Initiate) on Jul 05, 2008 at 18:23 UTC | |
|
Re: Regex question
by pc88mxer (Vicar) on Jul 04, 2008 at 15:11 UTC | |
|
Re: Regex question
by olus (Curate) on Jul 04, 2008 at 15:22 UTC |