| Alexander Blüm 2005-01-17, 8:55 am |
| On Sun, 16 Jan 2005 18:36:09 +0500
"Sara" <sara_samsara@hotpop.com> wrote:
> I am trying to extract links along with HTML tags <a href=blah> from a
> list, but it's not working on my XP machine with Active State Perl
> 5.0.6 Kindly help.
>
> ################# CODE START ####################
>
> my @array = qq|
> <body><a href="http://www.mydomain.com"><img alt="Free Hosting,
> Freebies" border=0
> src="http://www.mydomain.com/images/logo2.gif"></a>|;#extract LINKS
> (no image links) only <a href="http://www.mydomain.com">
>
> my @get = grep {/<a .*?>/} @array;
> print "@get\n"
>
> ################### CODE END ###################
>
> Thanks,
>
> Sara.
>
this is also possible _without_ any modules, except maybe "strict".
# this will replace the contents of each match in @get
foreach(@array){
my @get = $_ =~ /<a href="(.*?)">/g;
}
or:
# this will add each match to @get
my @get = ();
foreach(@array){
push @get, $_ =~ /<a href="(.*?)">/g;
}
--
Cheers,
Alex
|