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

Thankyou all,
This fella is great and exactly what I'm after since the start and end regexes appear only once per file as a nice set and never appear on the same line...
perl -ne 'print if /start/ .. /end/' *.html
My problem is now due to my WinNT shell (CMD.exe) not being able to read the quotes and deal with the glob!
sigh!

Replies are listed 'Best First'.
Re: Re: I'm looking for a one-liner filter 'twixt two regexes
by Corion (Patriarch) on Sep 05, 2002 at 16:58 UTC

    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
      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.
Re: Re: I'm looking for a one-liner filter 'twixt two regexes
by RMGir (Prior) on Sep 05, 2002 at 15:25 UTC
    Wow. It boggles my mind that that works. But you're right, it does. (Edit: And looking at the perlop perldocs, now I see why. "bi-stable, like a flipflop", cool!)

    If you can install cygwin, use that. It will give you a "sane" shell to run perl scripts with.
    --
    Mike