Other Monks have given you advice to help with your problem. I would just like to point out what seems to be some slightly topsy-turvy logic in your code and give some advice regarding opening files. Your code

$append = 0; if ($append) { open(MYOUTFILE, ">clean_text"); #open for write, overwrite } else { open(MYOUTFILE, ">>clean_text"); #open for write, append }

looks like you are overwriting if $append is true and appending if it is false. Perhaps a little misleading?

The use of the three argument form of open is to be encouraged as is the use of lexically scoped filehandles. You should also test that the open succeeded. Most importantly, putting the lines use strict; and use warnings; at the top of your scripts will save you a lot of wasted time in the long run as it will help you spot typos like

$append = 1; ... if ( $apped ) { # Append to my file } else { # Trample all over my irreplaceable data }

Using strictures, three argument open and lexical handles your piece of code might look like

my $append = 0; my $cleanedFile = q{clean_text}; if ( $append ) { open my $cleanedFH, q{>>}, $cleanedFile or die qq{open: $cleanedFile for append: $!\n}; } else { open my $cleanedFH, q{>}, $cleanedFile or die qq{open: $cleanedFile for overwrite: $!\n}; }

I hope these thoughts are of use.

Cheers,

JohnGG


In reply to Re: html into an array by johngg
in thread html into an array by monkeybus

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.