Thanks for the replies! Since people have asked what I'm trying to do, I've included a copy of the actual code below.

I have another program that regex-searches lengthy documents and tries to sort the paragraphs into categories based on keywords. The other program colours the text of the various paragraphs based on what category it thinks it fits into, and then human assistants go over the coloured document to check that the categorization is correct. If it isn't, the human assistants change the text colour to the appropriate value manually. The files are in RTF format.

The purpose of the second program is to take the correctly-coloured document and split in into six new files (one for each category). The code I have written effectively (although inelegantly) identifies the text colour of each paragraph. I then want to write the text of the paragraph to the appropriate file, based on the text colour of the paragraph.

use diagnostics; use File::Slurp; use RTF::Writer; my @destinations = ('IAs','Defs','Term','Payoffs','RWs','Boilerplate2' +); my $targetfolder = "contract/new2"; opendir(DIR, "$targetfolder"); my @files = readdir(DIR); closedir(DIR); my $count = 0; foreach $file (@files) { if ($file =~ /rtf/i) { my $IAs = RTF::Writer->new_to_file("contract/IAs/$file") +; my $Defs = RTF::Writer->new_to_file("contract/Defs/$file +"); my $Term = RTF::Writer->new_to_file("contract/Term/$file +"); my $Payoffs = RTF::Writer->new_to_file("contract/Payoffs +/$file"); my $RWs = RTF::Writer->new_to_file("contract/RWs/$file") +; my $Boilerplate2 = RTF::Writer->new_to_file("contract/Bo +ilerplate2/$file"); my $contract = read_file("$targetfolder/$file"); my @paragraphs = split('cf', $contract); foreach $clause (@paragraphs) { my @lines = split("\n", "$clause"); if ($lines[0] =~ /^\d$/){ my $colour = $lines[0]; my $goal = \${$destinations["$colour"]}; #P +ROBLEM CODE my $destinationfolder = ("contract/$goal"); foreach $line (@lines) { if ($line =~ /^\s*\w/ && $line !~ /^\d$ +/){ ${$goal}->paragraph ( "$line", ); } } } } } $count++; }

Essentially, I want to fix the line marked "#PROBLEM CODE", above. I'm going to go over the replies and links above to see if I can figure out a solution. Thanks again!


In reply to Re: Symbolic Reference in Method Call by EclecticScion
in thread Symbolic Reference in Method Call by EclecticScion

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.