in reply to Re^5: Formatting
in thread Formatting

John,
The "#" in my code would be a comment, but it should be translated to a <!-- Whatever comment -->, not completely ignored.

I really appreciate your help, and if you have AOL/ICQ/MSN or e-mail, please let me know so we can discuss this in a simpler manner.

Thanks again,
Marcos

Replies are listed 'Best First'.
Re^7: Formatting
by wfsp (Abbot) on Jul 13, 2004 at 11:14 UTC
    Add another record:
    '#' => { open => '<!-- ', close => ' -->', block => 0 }
    The key needs quotes ('#'). Make sure you have a comma after the previous record
    Remove:
    next if $line_in =~ /^#/; # skip comments
    wfsp
      John,
      Ok, i'll try that again.

      Anyways, the script is like 95% complete, all i have to implement now (which i have partially done) is an alternate $tag, depending on whether there is a special character in every block.

      I have done this with a subroutine:

      sub piper_end() {

      my $tag = { K => { open => '%',
      close => '',
      block => 1,
      block_open => "<c>\n".'<p>',
      block_close => '</p>'."\n<t>"
      },
      R => { open => '<li>',
      close => '</li>'."\n",
      block => 1,
      block_open => '<r>'."\n",
      block_close => '</then>'."\n".'</ifflag>'."\n".'</r>'."\n</t>\n</c>"
      },
      S => { open => '<set name="temant">',
      close => '</set>',
      block => 0
      },
      F => { open => '<setflag param="',
      close => '"/>',
      block => 0,
      }
      };

      return $tag;
      }

      Now if a $style tag matches this special character (I), it will call upon the subroutine to update a specific block_close (for R). Is this method alright?

      Thanks again,
      Marcos
      John,
      By the way, I know why the '#' wasn't working, because of the regular expression when spliting:
      my ( $style, $content ) = $line_in =~ /^(\w)\s+(.*)$/;

      I've converted it to:
      my ( $style, $content ) = $line_in =~ /^(\w|\#)\s+(.*)$/;

      And now it works properly :)
      Let me know what you think on the previous question, the one on the subroutine.

      Thanks.
      Best Regards,
      Marcos