Hi Kevin

just hints, no solution :-)

Am Montag, 25. April 2005 12.59 schrieb Kevin Horton:
> I'm trying to write a perl one-liner that will edit an iCalendar
> format file to remove To Do items.  The file contains several
> thousand lines, and I need to remove several multi-line blocks.  The
> blocks to remove start with a line "BEGIN:VTODO" (without the quotes)
> and end with a line "END:VTODO" (also without quotes).
>
> I've tried the following one-liner,
>
> perl -p -i.bak -e 's/BEGIN:VTODO.*END:VTODO//sg' file_name_to_edit

according to perldoc perlrun, -p reads _one_ line after the other, so you 
can't search for multiline patterns this way.

> The .bak file is created, which tells me the one-liner is finding my
> file, but the file is identical to the old one - i.e. the regex
> doesn't seem to be matching anything.
>
> I'm also wondering whether my proposed one-liner (if it worked) would
> be too greedy.  

yes or no, depends from the working implementation :-)

> Would it pull out everything between the first 
> BEGIN:VTODO and the last END:VTODO?

yes, if you try to match a string with the whole file in it with the regex 
above.

>
> I'd appreciate any hints.
>
> Thanks,
>
> Kevin Horton

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


Reply via email to