lorenw14 has asked for the wisdom of the Perl Monks concerning the following question:

I have been working on converting files to a one-line explicit command line to the Perl interpreter but I have no idea how to do this one.

while(<>){ while(/A\s+HREF\s*=\s*"([^"]+)"/ig){ $foo{$1}=1; } } for(keys %foo){ print "<img src=\"$_\"><br>\n"; }

Edit 2001-04-16 by Corion : Added <CODE> tags

Replies are listed 'Best First'.
(sacked: HTML::LinkExtor) Re: one line programs
by sacked (Hermit) on Apr 16, 2001 at 05:28 UTC
(Buzzcutbuddha - Formatting of question) - Re: one line programs
by buzzcutbuddha (Chaplain) on Apr 16, 2001 at 05:28 UTC
    your example would be easier to follow if enclosed in
    <code></code> blocks.

    It works similar to the PRE tags in HTML.

    I imagine you were downvoted because the code is hard
    to read:
    { while(/A\s+HREF\s*=\s*"(^"+)"/ig) { $foo{$1}=1; } } for(keys %foo) { print "\n"; }
    Is this the code you had in mind?
      Sorry about that, this is the first time that I have used this site and I was not quite sure how to use the but I think that I got it now. Yeah, the code that I was trying to convert to a one-liner was
      while(<>) { while(/A\s+HREF\s*=\s*"([^"]+)"/ig){ $foo{$1}=1; } } for(keys %foo){ print "<img src=\"$_\"><br>\n"; }
      Thanks for your help.
      Sorry about that, this is the first time that I have used this site and I was not quite sure how to write in the code but I think that I got it now. Yeah, the code that I was trying to convert to a one-liner was
      while(<>) { while(/A\s+HREF\s*=\s*"([^"]+)"/ig){ $foo{$1}=1; } } for(keys %foo){ print "<img src=\"$_\"><br>\n"; }
      Thanks for your help.