Hi all,
I have an array that holds the source code to a cobol program. I then
have a number of integers that hold the subscript for section and
division changes.
I then have subs that parse sections of that array. e.g. a sub called
file_control will parse the file-control section and extract
information from the file select statements.
At the moment my code works because I store the array as a global
variable and pass to the sub the start and end array elements.
I want to now make my code a bit more flexible and simply pass a
reference to the section I require. The code I've tried may give a
better idea of what i mean. when I run my code I get the following
error on the 'foreach (@$lines)' line
Not an ARRAY reference at ./s line 109.
I could simply pass the array sections to the subroutines but that
would be very inefficient - the procedure divisions of some the
programs are 5k lines - hence the attempt to reference.
my @lines=( # simulate read cobol file
........
" file-control.\r\n",
" select jobfile\r\n",
" assign external das1\r\n",
" organization is indexed\r\n",
" access dynamic\r\n",
" record key is job-jf-key\r\n",
" file status is w01-jobf-stat\r\n",
" lock mode is automatic with rollback.\r\n",
.......
&file_control(\@lines[10..36]); # pass pointer to array elements 10-36
sub file_control() {
my ($lines)=@_;
foreach (@$lines) { # process each line in array section
next if (/^ [\/\*]/);
........
--
Gary Stainburn
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000