in reply to Re: I'm looking for a one-liner filter 'twixt two regexes
in thread I'm looking for a one-liner filter 'twixt two regexes

cmd.exe quoting rules are almost simple. There is only one kind of quote, the double quote. So

perl -ne "print if /start/ .. /end/" *.html
works. I'm not sure how you escape a double quote on the command line of cmd.exe, so I use qq(\n) whenever I need to embed a newline...

perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web

Replies are listed 'Best First'.
Re: Re: Re: I'm looking for a one-liner filter 'twixt two regexes
by msemtd (Scribe) on Sep 06, 2002 at 12:44 UTC
    Aw! I get...

    C:\temp\>perl -n -e "print if /start/ .. /end/" *.html
    Can't open *.html: Invalid argument.

    When run under CMD.exe -- I'm not sure if it's perl.exe or CMD.exe complaining here. :(
    Msemtd.
      Many Thanks to all who replied -- my solution to the CMD.exe problem was resolved with a WinNT batch file(!) to deal with the "*.html" argument...
      @echo off :: aarunme.bat -- on an NT machine with ActiveState Perl, this fella :: will tidy up a mirror of the Slackware Book by exploding the inner +table for %%f in (*.html) do call :func1 %%f goto :EOF :func1 echo %1 perl -ni.bak -e "print if /Norman/ .. /\/BODY$/" %1 :: this line replaces the missing ">" for the closing body tag echo ^> >> %1
      BTW: I really should have the 2nd regex on the closing HTML tag.