Hi, I've created a very basic Perl script to generate combinations of words:
use strict; use warnings; use Algorithm::Combinatorics qw(combinations); my $strings = [qw(Word1 Word2 Word3 Word4)]; my $iter = combinations($strings, 2); while (my $c = $iter->next) { print "@$c\n"; }
How would I go about using words from a .txt file rather than manually adding them (GGGG CCCC...). I understand the basics of opening and reading (line-by-line) files in perl but I am not sure how to use this data within the above script. My .txt file is essentially:
Word1 Word2 Word3 Word4
And so on. Can I use something like:
open (DATA, "text.txt"); @Test = <DATA>; close DATA;
To open/read it? Not sure how to then get Perl to use the loaded data. Can anybody offer any assistance? Thanks!
In reply to Using imported .txt file with Algorithms::Combinatorics by TJCooper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |