Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^4: Regex for removing Template::Toolkit comments?

by bliako (Monsignor)
on Aug 27, 2018 at 10:41 UTC ( [id://1221179]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Regex for removing Template::Toolkit comments?
in thread Regex for removing Template::Toolkit comments?

In my attempts I have omitted @_ and and was getting Use of uninitialized value $_, but forgotten about when you call it later on without any params. So, that works for multiline comments but not single line. I have put the following test input which I presume is valid Template::Toolkit comment syntax with the exception of nested comments which I am not sure. I will go the Parser way haukex posted. thanks

[%# comment nust be removed 1 %] [% # comment nust be removed 2 must stay 0 %] [% # comment nust be removed 3 must stay 1 %] [% # comment nust be removed 4 must stay 2 # comment nust be removed 5 [%# nested comment (not sure if allowed or not) 1 %] %] [%# comment nust be removed 6 comment nust be removed 7 comment nust be removed 8 [%# nested comment (not sure if allowed or not) 2 %] %] [% # comment nust be removed 9 [% comment nust be removed 10 %] [% # nested comment (not sure if allowed or not) 2 %] %] [% must stay 3 %] [% must stay 4 must stay 5 # comment nust be removed 11 %] [% # comment nust be removed 12 must stay 6 %]

Replies are listed 'Best First'.
Re^5: Regex for removing Template::Toolkit comments?
by tybalt89 (Monsignor) on Aug 27, 2018 at 13:16 UTC

    Both

    comment nust be removed 9

    and

    comment nust be removed 10

    are incorrect, they should both stay under the rules you posted.

      sorry, yes you are right

      [% # this is a comment to the end of line foo = 'bar' %] [%# placing the '#' immediately inside the directive tag comments out the entire directive %]
      (http://www.template-toolkit.org/docs/modules/Template.html#section_COMMENTS)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1221179]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-03-29 06:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found