Getting lines from a website with GET and ack
Oh no, hourly smoke test failures in my inbox today! Looks like I put some bad HTML on work's website's home page, and every hour one of the automated tests, via Test::HTML::Lint, told me once an hour that
# HTML::Lint errors for http://devserver.example.com/ # (72:53) <a> at (61:53) is never closed
Well, phooey, it's a PHP-driven website, so I can't open index.php and check lines 72 and 61. I can use GET, installed with LWP, to fetch the website and save the source:
$ GET http://devserver.example.com/ > foo.html $ vim foo.html +61
but since I'm a Perl programmer, I want to be as lazy as possible by using the tools at my disposal. In this case, it's ack, and ack has the --line option to display ranges of lines instead of results of a regex. (Thanks to Torsten Blix for implementing this!)
$ GET http://devserver.example.com/ | ack --lines=61-72
So much nicer that way! and look at it in an editor, but how much easier to not have to do that.