in reply to Re^2: Converting a source code
in thread Converting a source code
You ought not have got a blank target file. However there was a bug in the code. $_-[0] in the regular expression should have been $_->[0].
For test purposes it is conventient to use a __DATA__ section following the code and to print to the console. A test version of the code is:
use strict; use warnings; my @pairs = ( ['WORKING -STORAGE SECTION.', 'declare'], ['PROGRAM -BEGIN.', 'begin;'], ['^DISPLAY', 'PUT'], ['^ACCEPT', 'GET'], ['PROGRAM -DONE.', 'END;'], ); while (defined (my $line = <DATA>)) { $line =~ s/$_->[0]/$_->[1]/ for @pairs; print $line; } __DATA__ WORKING -STORAGE SECTION. PROGRAM -BEGIN. DISPLAY ACCEPT PROGRAM -DONE. this DISPLAY not changed this ACCEPT not changed this PROGRAM -DONE. should get fixed
Prints:
declare begin; PUT GET END; this DISPLAY not changed this ACCEPT not changed this END; should get fixed
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Converting a source code
by oblate kramrdc (Acolyte) on Aug 24, 2006 at 22:00 UTC |