#!/usr/bin/perl
use strict;
use warnings
my $file = "Name.txt";
open(IN, "<", $file) or die "I cannot open a file: $file ";
# close file:
close IN;
####
#!/usr/bin/perl
use strict;
use warnings
my $file = "Name.txt"
open(IN, "<", $file) or die "I cannot open a file: $file ";
while(my $line =){ ## reading a file line by line
# here you need to put some regular expression to identify your web addresses
}
####
www.1 5
www.2 7
www.3 2
...
####
#hey, what is my current count for www.2 ?
my $value = $hash{"www.2"};
print "$value\n"; # What does "\n" stand for?
####
#!/usr/bin/perl
use strict;
use warnings
my $file = "Name.txt";
open(IN, "<", $file) or die "I cannot open a file: $file ";
my %hash = ();
while(my $line =){ ## reading a file line by line
# here you need to put some regular expression to identify your web addresses
# from regular expression extract the WWW address and put it into some variable like my $www = $1;
#hey, what is my current count for some www ?
my $value = $hash{$www};
#OK, cool add one to it :)
$value = $value + 1;
#Good, now put it back.
$hash{$www} = $value;
}
#close file
close IN;
# Print my averages
foreach my $key (keys %hash){
print "$key\t" . (($hash{$key}/$total)*100) . "\%\n"; # hey where did my $total come from (I'll leave that to you :))?
}