The biggest problem in your posted code is that you have meaningless variable names. Your particular choice of meaningless names is also problematic, as $1 is used to store the results of regular expression matches, so if you later add any code which captures portions of a string using a regex, you'll be at high risk of suddenly developing bugs of a sort which are
very difficult to track down.
As another bit of general advice, you should always "use strict" along with "use warnings". (There are times when you need to do something "strict" won't allow, but they're few and far between.)
Just applying minor cleanup to your posted code:
CODE
#!D:\Perl\bin\perl
use strict;
use warnings;
open my $outfile, ">>", "words.txt";
#This is the array of characters I want my words to make.
my @word_characters = (0 .. 9);
foreach my $character (@word_characters) {
print $outfile "$character\n";
}
close $outfile; # You can get away without this, but it's a good habit
I removed the BEGIN block because you didn't need it. Although it's not entirely accurate, you can think of BEGIN blocks as executing while the program is being compiled, before it actually runs. You don't need to open the file until the program starts running, so it shouldn't be in a BEGIN. (This also means that code in BEGIN blocks will run when you syntax-check your code with "perl -c", which would not normally be a sensible time for you to be opening files.)
I also removed your $1++ (or $character++, with the new variable names) line because the foreach loop already handles the process of walking through the list for you. $character is automatically reassigned to the next value in @word_characters at the end of each iteration, so you don't need to increment anything yourself and, actually, the incremented value would just be thrown away anyhow when the foreach overwrote it.
The "my" before the first use of each variable is there to declare it (and assign its scope, but I won't get into a discussion of variable scoping just now). This is one of the things required by "strict" and helps to protect you against bugs caused by typos in variable names as well as preventing you from accidentally creating global variables.
Changing the definition of @word_characters to "(0 .. 9)" makes it a little more compact while still doing the same thing. More importantly, this will save you from having to worry about whether you missed or duplicated anything when you add letters and can just say "( 0 .. 9, 'a' .. 'z', 'A' .. 'Z' )". Unfortunately, you can't use .. in a qw list (it will just give you a literal ".."), but I think that's a more-than-worthwhile tradeoff here.
Just a plain "print" will send output to STDOUT - generally the console window where the program is running. I changed it to "print $outfile" so that output will instead go to the file opened on the filehandle $outfile. (Bonus points for using a lexical filehandle and three-argument open, by the way!)
Anyhow, with this cleanup, you now have a well-written Perl program which prints out the list of values contained in @word_characters. Now you just need to add some code to give you combinations of multiple characters - I would suggest looking into recursion as a way to do this.