[Israel.pm] patterns findings

sawyer x xsawyerx at gmail.com
Wed Mar 18 04:31:23 PDT 2009


For the first task, you can just has the values.
use File::Slurp;
foreach my $line ( read_file($filename) ) {
    $hash{$line}++;
}
while ( my ( $key, $value ) = each %hash ) {
    if ( $value > 1 ) { print $value }
}

As for the other, that's pretty complex unless you have specific patterns...

On Wed, Mar 18, 2009 at 1:10 PM, Yossi Itzkovich
<Yossi.Itzkovich at ecitele.com> wrote:
>
> Hi,
> I am looking for a module that will get a file with text lines, and will find repeating patterns.
> Example:  given the following file:
> -----
> I want to go home
> 1+3=4
> Hello World
> 1+3=4
> Hello World
> 8+2=10
> Hello World
> Klskd
> -----
> The script should tell me that the sequence : 1+3=4  and Hello World repeat 2 times.  A better script may tell me even that the more general pattern: {number}+number}={number} and Hello World  repeat 3 times.
>
> Any suggestion?
>
> Thanks
> Yossi
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl


More information about the Perl mailing list