For example,
@seed = ('seed_1', 'seed_2', 'seed_3', 'seed_4);
However, in the future there could be more than seed_4. How can I make this as general as possible? Meaning I don't have to manually write the future seed_. It can be 'seed_50' or random values.
example:
$file ='text.txt';
for my $seed (@seed)
{
if (open my $data, "<", $file)
{
my $line =<$data>;
print "ERROR: $line\n";
}
close $data;
}
the seed_ are actually folders in directories. So, I need to go through every seed to open the text file but I may not know the values in every seed folder. The dir are directories I need to open. I just need to read out the first line of the text.
so for example:
for my $dir (@dir){
for my $seed (@seed)
{
if (open my $data, "<", $file)
{
my $line =<$data>;
print "ERROR: $line\n";
}
close $data;
}
}
seed_\d+.@array = ('seed_1', 'seed_2', 'seed_3', 'seed_4');. But in the future, there may be more than this. Is there a way to automatically match the pattern without writing out manually theseed_?@seedelements involved? (Do you mean to test whether any of$seedmatches, for each$line? Or something else?)# check whether $seed matches $lineor some such)$seed?!? Did you use$filewhere you meant to use$seed? If so, you wantglob("\Q$dir\E/seed*")