Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Whenever "EX" instruction is there in the first column followed by 2 arguments, whatever is there in the 2nd argument will be another routine(this routine will be in the same file.). that has to be substituted in place of the entire EX statement..

Okay, so you would need 3 passes.

  1. Load the file into an array line-by-line: my @file = <$fh>;
  2. Scan the lines and record the routine names from the EX statements:
    my %exs; $file[ $_ ] =~ m[\s+EX\s+[^,]+,(\S+)] and push @{ $exs{ $1 } }, $_ for + 0 .. $#file;
  3. Now locate the routines referenced in the EX lines and make the substitutions:
    for my $rtn ( keys %exs ) { my $n = 0; ++$n until $file[ $n ] =~ m[$rtn\s+(\S+)]; my $subst = $1; $file[ $_ ] = "\t$subst" for @{ $exs{ $rtn } }; }
  4. Write out the modified array to a new file.

Of course, that only deals with single line substitutions; you'd need to add error checking for routines referenced but not found; and you might want to remember the lines where the substituted routines were found and remove them before output; etc. but that should get you started.

As OGB said; I can't believe that there isn't an ISPF macro to do this already in existance.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?


In reply to Re^3: is it possible? by BrowserUk
in thread is it possible? by suno

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-19 22:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found