Perl 与 Ultraedit 脚本编写
我想知道 Perl 是否是一个很好的(易于使用和学习)工具:
我想对我的 C/C++ 源代码进行一些自定义预处理。基本上,这是为了允许我将自己的自定义注释插入源代码并基于它生成新代码。所需的处理主要是面向行的搜索/替换和插入新的源代码行。
我现在可以想到 2 个工具来实现此目的:(1) Ultraedit 的脚本功能(或任何其他有能力的编辑器)。 (2) Perl 脚本。
Ultraedit 的脚本看起来不错,我也很熟悉。最重要的是,它自然的面向行的处理是处理源代码行的良好抽象。
我想知道 Perl 是否也是一个好工具。除了熟悉在其他上下文中使用的 Perl 风格 Regexpr 之外,我对 Perl 的经验为零。 Perl 是面向行的文本处理的好工具吗?我必须向前和向后搜索,并用一些其他文本替换源代码行。
I'm wondering if Perl is a good (easy to use and to learn) tool for this:
I'd like to do some custom preprocessing on my C/C++ source code. Basically, this's to allow me to insert my own custom annotations to the source code and generate new codes base on it. The required processing is mainly line oriented search/replace and insertion of new source code lines.
I can now think of 2 tools to achieve this: (1) Ultraedit's scripting feature (or any other capable editors). (2) Perl scripting.
Ultraedit's scripting looks good and I'm familiar with it. Best of all, its natural line oriented processing is a good abstraction for processing source code lines.
I'm wondering if Perl is also a good tool. I've ZERO experience with Perl except that I'm familiar with Perl style Regexpr used in other contexts. Is Perl a good tool for line oriented text processing? I'll have to search forward and backward and replace source code lines with some other texts.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您熟悉 Perl,那么 Perl 是一个出色的工具。它本质上是针对这种文本分析和翻译的,因此您会发现它具有您可能要求的所有扩展。
另一种选择是使用 UltraEdit 的 JavaScript 功能。它的执行速度比 Perl 中的执行速度要慢一些,但它提供了一个不错的用户界面,您可以使用 UltraEdit 来指示要在何处进行更改。此外,UltraEdit JavaScript 比 UltraEdit 脚本具有更大的灵活性。
我个人不能推荐使用Python,但我目前是一家公司计划的一部分,旨在将它用于此类功能,所以希望前面的回答者是正确的。
Perl is an excellent tool for this if you are familiar with it. It's essentially geared towards that kind of text analysis and translation, so you'll find that it has all of the extensions you could ask for.
Another option is to use UltraEdit's JavaScript functionality. The execution speed on it is a little slower than what you can get in Perl, but it provides a decent user interface where you can use UltraEdit to indicate where you want the changes to be made. Also, UltraEdit JavaScript has a great deal more flexibility than UltraEdit scripting.
I can't personally recommend Python for it, but I'm currently part of a company initiative to use it for exactly that kind of function, so hopefully the previous answerer is right.
是的,Perl 是一个满足您需求的好工具。我会选择 Python,它快速、简单、美观,并且在 STL 中具有良好的正则表达式接口;但这纯粹是一个品味问题。
Yes, Perl is a good tool for what you want. I'd go for Python, it's quick, easy, beautiful and has a good regex interface in the STL; but it's purely a matter of taste.