Hi Jenn.

Its interested ;)

How's it?

#!/usr/bin/ruby

regex =3D /href=3D"http:\/\/(.*?)\/.*" target=3D"_blank"/

File.open("index.html") do |f|
  f.each_line do |c|
    puts $1 if c =3D~ regex
  end
end

2010/1/4 Ruby Newbee <rubynewbee / gmail.com>:
> Hi,
>
> I wrote this message without other purpose, just show a result for
> comparison. :-)
>
> First I got the page which will be used for analysis (got all domain
> names from it):
>
> wget http://www.265.com/Kexue_Jishu/
>
> It will get an index.html page.
>
> Then I run this ruby script:
>
> #!/usr/bin/ruby
>
> f =3D File.open("index.html")
>
> f.each_line do |c|
> =A0 =A0puts $1 if /href=3D"http:\/\/(.*?)\/.*" target=3D"_blank"/ =3D~ c
> end
>
> f.close
>
>
> And this perl script:
>
> #!/usr/bin/perl
>
> open HD,"index.html" or die $!;
> while(<HD>) {
> =A0 =A0print $1,"\n" if /href=3D"http:\/\/(.*?)\/.*" target=3D"_blank"/;
> }
> close HD;
>
>
> When using "time" command to see the running time, I saw ruby is
> slower than perl (maybe due to the regex?).
>
> Ruby's:
>
> real =A0 =A00m0.013s
> user =A0 =A00m0.012s
> sys =A0 =A0 0m0.000s
>
> Perl's:
>
> real =A0 =A00m0.004s
> user =A0 =A00m0.004s
> sys =A0 =A0 0m0.000s
>
> Both versions:
>
> # ruby -v
> ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-linux]
>
> # perl -v
> This is perl, v5.8.8 built for i486-linux-thread-multi
>
>
> Yes that's the result, but not influence me to love ruby.
>
>
> Thanks.
> Jenn.
>
>