Stan Schwertly on 28 Oct 2011 08:03:23 -0700

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Philadelphia-pm] Perl one liner, regex capture group problem

I wrote this one-liner for a friend, and wanted to replace the end with Perl. It pulls out the image sources from a URL:

command: curl -so-|egrep -o "src="" -c 5-
abbreviated output:

I tried to replace it with the following command, but it doesn't seem to be respecting the capture group:

command: curl -so-|perl -nE "say $1 if /src="">
abbreviated output:
                                <a href="" href="">'><img class='rounders2_img' alt='' src="" href="">' />

                                <img class='rounders2_sprite' alt='' src="" href="'/">'/>

It's printing the matched line, but doesn't populate $1 correctly. What should I change?

Stan Schwertly
Philadelphia-pm mailing list