in reply to Re^2: Using imported .txt file with Algorithms::Combinatorics
in thread Using imported .txt file with Algorithms::Combinatorics

in a complicated way:

my $strings = \@test;

easier

@$strings = <$filehandle>;

ATM I'm in a hurry ... others might recommend you books. =)

Cheers Rolf

( addicted to the Perl Programming Language)

Replies are listed 'Best First'.
Re^4: Using imported .txt file with Algorithms::Combinatorics
by TJCooper (Beadle) on Jan 08, 2014 at 13:01 UTC

    Thank you for the help! That has clarified some things for me.

    #!/usr/bin/env perl open (my $data, "<", "test.txt") or die "There was a problem opening: +$!"; my @primers = <$data>; close $data; chomp @primers; use strict; use warnings; use Algorithm::Combinatorics qw(combinations); my $strings = \@primers; my $iter = combinations($strings, 2); while (my $c = $iter->next) { print "@$c\n"; }

    I'm now running this and it mostly does what I intended it to do. My output ends up putting an unwanted space in-between the 2 words that were combined. Is this because i'm stringifying?

      an unwanted space in-between the 2 words that were combined
      Replace the print statement with something like:
      print join('',@$c) ."\n";
        Or, golfed,
        print @$c, "\n";
        لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ