CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Need help with comment remover code...

 



Nila
User


Sep 28, 2010, 10:15 PM

Post #1 of 4 (2033 views)
Need help with comment remover code... Can't Post

I need a help with Perl code.

Scope is,
I want to remove the comments in Rails code. I need a comment remover code in Perl. Can any one help me?

Thanks in advance...


rovf
Veteran

Oct 21, 2010, 8:07 AM

Post #2 of 4 (1915 views)
Re: [Nila] Need help with comment remover code... [In reply to] Can't Post

Sure, just post that (not too large) piece of code you are having problems with...


BillKSmith
Veteran

Oct 22, 2010, 6:22 AM

Post #3 of 4 (1894 views)
Re: [Nila] Need help with comment remover code... [In reply to] Can't Post

You can remove perl comments with a one line command. Is the syntax of rail comments the same?

Refer to -i and -p in perldoc perlrun.


Code
perl -pi.bak -e"$_ = <> if /^\s*#/" your_file.pl



Your OS may require single quotes rather than double.
Good Luck,
Bill


rovf
Veteran

Nov 2, 2010, 7:47 AM

Post #4 of 4 (1736 views)
Re: [BillKSmith] Need help with comment remover code... [In reply to] Can't Post

This does not remove *all* comments, and it might even remove lines which are NOT comments.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives