arsoncupid has asked for the wisdom of the Perl Monks concerning the following question:
I'm not sure what's going on here, for some reason my array keeps growing as I look at each entry in the array.
This script looks at one .TAB file, compares each line's second tab stop text (probably very inefficiently) to all the other line's second tab stop text. I'm looking for duplicates.
This is on Mac panther, BTW. ... perl5 (revision 5.0 version 8 subversion 1 RC3)
#!/usr/bin/perl $| = 1; open ( ADDS, "./additions.tab" ); while ( $line = <ADDS> ) { chomp ( $line ); @div = split ( /\t/, $line ); $blip = 0; # increment integer, keeps track of tab stops foreach my $atom (@div) { @{$lines[$lino]}->[$blip++] = $atom; } $lino++; # increment integer, keeps track of lines } close ADDS; foreach my $Line (@lines) { $dinky = 0; # toggle integer, for existance of duplicates $startat++; # duel use. # 1 Keeps track of already inspected lines, to avoid redoing that work # 2 Let's me see output by printing every few lines foreach my $tick ($startat..( scalar ( @lines ) )) { if ( $lines[$tick]->[1] eq $Line->[1] ) { print (join ( "\t", ( @{ $lines[$tick] } ) ) +) . "\n"; $dinky++; } } print (join ( "\t", ( @{$Line} ) )) . "\n" if ( $dinky > 0 +); print STDERR $startat . "\n" if ( !( $startat % 100 ) ); print STDERR "(" . scalar ( @lines ) . ")\n" if ( !( $startat +% 100) ); }
Sample Output:
100 (2506) 200 (2606) 300 (2706) 400 (2806) 500 (2906)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Oddly growing array
by revdiablo (Prior) on Oct 05, 2005 at 18:04 UTC | |
|
Re: Oddly growing array
by Roy Johnson (Monsignor) on Oct 05, 2005 at 17:55 UTC | |
|
Re: Oddly growing array
by sk (Curate) on Oct 05, 2005 at 16:52 UTC | |
|
Re: Oddly growing array
by Tanktalus (Canon) on Oct 05, 2005 at 18:19 UTC | |
|
Re: Oddly growing array
by InfiniteSilence (Curate) on Oct 05, 2005 at 18:03 UTC | |
|
Re: Oddly growing array
by arsoncupid (Initiate) on Oct 05, 2005 at 18:43 UTC |