$PatternToMatch="^SELECT";
$tmpfile="pattern.txt";
open(MYFILE, "$tmpfile")|| die "Cannot create $tmpfile\n";
while (<MYFILE>) {
if (/$PatternToMatch/)
{
push (@array, $_);
}
}
As you are reading the file, you need to push every time perl founds Select to and array, because the variable get overwritten with every success match.
After that, recover all the data from the array when you need.
foreach $control (@array) {
print "Line -> $control\n";
}
In reply to Re^4: Output in variable
by Sombrerero_loco
in thread Output in variable
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |