I am not sure what is going on with this code, I believe it has something to do with how my variables are scoped, but changing them from "my" to "our" doesn't do anything. The error comes in the second if block where I try to get it to print $question1, perl says that "$question1 requires a specific package name". The code there is just a test for what I need to do later in the program. I just need the $question variables to be able to be used throughout my program.
foreach my $line ( split /:/, $test ) {
my $match1 = "1";
my $match2 = "2";
if ( $line =~ /$match1/ ) {
my $question1 = $line;
print "$question1\n";
}
if ( $line =~ /$match2/ ) {
my $question2 = $line;
print "$question2\n";
print "$question1\n";
}
}
$question1do you expect to be printed in case$match1doesn't match and$match2does?