Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: regex subst not DWIM

by suaveant (Parson)
on Dec 19, 2007 at 22:14 UTC ( [id://657985]=note: print w/replies, xml ) Need Help??


in reply to regex subst not DWIM

With a program this size with a vague dataset it would be helpful to have an input file with an example of what output you want to get, then we could actually run it. Just a minimal dataset will do.

                - Ant
                - Some of my best work - (1 2 3)

Replies are listed 'Best First'.
Re^2: regex subst not DWIM
by girarde (Hermit) on Dec 19, 2007 at 22:22 UTC
    Here you go:
    public virtual void Destroy(object O) { try { m_container.Mockery.VerifyAllExpectationsHaveBeenMet() +; } finally { m_container = null; } }
      Ok... first problem I see (besides the params regexp already pointed out... is your not_method regexp piece...

      you didn't put it in a container, so your pipes aren't doing what you expect...

      if ($line =~ /^\W*(?:$not_method)/) {
      That'll work better.

      Update a \b at the end would also help make sure you don't match a string starting with as or if etc...

      if ($line =~ /^\W*(?:$not_method)\b/) {

                      - Ant
                      - Some of my best work - (1 2 3)

      And what should it look like once converted? When I run it I see it getting the copyright and nothing else changes.

                      - Ant
                      - Some of my best work - (1 2 3)

        It should look like:
        /// <summary> /// public virtual void Destroy(object O) /// </summary> /// <param name = "O">object</param> public virtual void Destroy(object O) { try { m_container.Mockery.VerifyAllExpectationsHaveBeenMet() +; } finally { m_container = null; } }
        Also, if the method dataset has no arguments, running it inserts a header (just the lines for summary) and appends another empty pair of parens to the declaration line. In other words, this as the dataset:
        public virtual void Destroy() { try { m_container.Mockery.VerifyAllExpectationsHaveBeenMet() +; } finally { m_container = null; } }
        results in this in the output:
        /// <summary> /// public virtual void Destroy() /// </summary> public virtual void Destroy()() { try { m_container.Mockery.VerifyAllExpectationsHaveBeenMet() +; } finally { m_container = null; } }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-19 04:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found