in reply to Re^3: Formatting
in thread Formatting

Thanks again!

Just got 2 questions that have arisen and should be easy to do now that you have kindly provided me with this script.

First, the simplest, how do I add the '#' as one of the first characters to check? I have tried adding another one of those blocks, but as you know Perl's comment character is #. Adding "\#" didn't help either. How can I express this in a way that will work without Perl interpreting it as a comment?

And lastly, how can I make the "K" statements be separated as "Perl,%Monks,%Is,%Cool"? I've experimented with adding a ",". For example:
my $tag = { K => { open => ',%',
close => '',
block => 1,
block_open => '<p>',
block_close => '</p>'

But as you probably realized, this has a nasty habit of adding an extra "," even to the first statement, as in ,%Perl,%Monks,%Is,%Cool .

I want you to know that I really appreciate the help you have provided so far, since I'm very close to having this finished and saving me tons of future hours :)

Best Regards,
Marcos

Replies are listed 'Best First'.
Re^5: Formatting
by wfsp (Abbot) on Jul 12, 2004 at 07:38 UTC
    Important: read the health warning below.

    Does a # in the data indicate a comment? If it does the code below skips lines begining with a #. If I have not understood you correctly, please give an example of the data.
    The code also adds a comma to each 'inline' style.
    I've added a variable to help make the code clearer.

    Health warning
    There is more than one way to do this! This is how I do it and it is heavily influenced by the fact that my main experience in coding is vb which makes most people around here shudder! For example, in Programing Perl, a long list of elsifs is frowned on. I tell myself that as I'm using the less well known 'baby idiom' (to be polite) it is ok. Until, at least, I learn a better way.
    Also my main motive for helping is to hone my own skills (which badly need honing).

      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
        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