On 6/20/07, Isnard Delacoste Jaquet Junior <[EMAIL PROTECTED]> wrote:

I have a simple question (hard for me that don't know perl though):
How do I search for a line and when found insert a comment in the
beginning of it?

Perl's comments run from the pound sign ("#") to end-of-line, so a
comment at the beginning means that the whole line is a comment to
Perl. It sounds as if you want to comment-out some line in a file.
Here's one way to do that to a line of data in $line that should be
commented out if it mentions fred:

 $line = "# $line" if $line =~ /fred/;

Is that the sort of thing you're looking for?

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to