I am writing out a textfile that has spaces throughout the file. What I need to do is put spaces in locations that may not have a value to put in. For example: $Reserve_1 requires 11 spaces in the field so my code looks like this..
sub checkData { my $zero = 0; my $space = ' '; if($Coverage_limits.length lt 11) { $Coverage_limits = ' '; } if($Reserve_1) { $Reserve_1 = ' '; } if($Coverage_entry_date != "") { my $year = substr(@row[3], 2, 2); my $month = $zero.@row[4]; my $day = $zero.@row[5]; $Coverage_entry_date = $year.$month.$day; } }
This does not work. Thanks for your help in advance.

In reply to I need a regExp to add spaces by Doyle

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.