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



Nila
User


Sep 28, 2010, 10:15 PM


Views: 3928
Need help with comment remover code...

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


Views: 3810
Re: [Nila] Need help with comment remover code...

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


BillKSmith
Veteran

Oct 22, 2010, 6:22 AM


Views: 3789
Re: [Nila] Need help with comment remover code...

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


Views: 3631
Re: [BillKSmith] Need help with comment remover code...

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